mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8351993: VectorShuffle access to and from MemorySegments
Reviewed-by: psandoz
This commit is contained in:
parent
afcbf6b2f4
commit
4d7068923c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -895,6 +897,25 @@ final class Byte128Vector extends ByteVector {
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_128;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Byte128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -927,6 +929,25 @@ final class Byte256Vector extends ByteVector {
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_256;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Byte256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -991,6 +993,25 @@ final class Byte512Vector extends ByteVector {
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_512;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Byte512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -879,6 +881,25 @@ final class Byte64Vector extends ByteVector {
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_64;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Byte64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -865,6 +867,25 @@ final class ByteMaxVector extends ByteVector {
|
||||
.intoArray(a, offset + species.length() * 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_MAX;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final ByteMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -864,9 +866,40 @@ final class Double128Vector extends DoubleVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Double128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -868,9 +870,40 @@ final class Double256Vector extends DoubleVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Double256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -876,9 +878,40 @@ final class Double512Vector extends DoubleVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Double512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -862,9 +864,40 @@ final class Double64Vector extends DoubleVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Double64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -861,9 +863,40 @@ final class DoubleMaxVector extends DoubleVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final DoubleMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -847,6 +849,12 @@ final class Float128Vector extends FloatVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Float128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -855,6 +857,12 @@ final class Float256Vector extends FloatVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Float256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -871,6 +873,12 @@ final class Float512Vector extends FloatVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Float512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -843,6 +845,12 @@ final class Float64Vector extends FloatVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Float64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -840,6 +842,12 @@ final class FloatMaxVector extends FloatVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final FloatMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -858,6 +860,12 @@ final class Int128Vector extends IntVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Int128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -866,6 +868,12 @@ final class Int256Vector extends IntVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Int256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -882,6 +884,12 @@ final class Int512Vector extends IntVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Int512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -854,6 +856,12 @@ final class Int64Vector extends IntVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Int64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -863,6 +865,12 @@ final class IntMaxVector extends IntVector {
|
||||
toBitsVector().intoArray(a, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final IntMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -865,9 +867,40 @@ final class Long128Vector extends LongVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Long128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -869,9 +871,40 @@ final class Long256Vector extends LongVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Long256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -877,9 +879,40 @@ final class Long512Vector extends LongVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Long512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -863,9 +865,40 @@ final class Long64Vector extends LongVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Long64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -863,9 +865,40 @@ final class LongMaxVector extends LongVector {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final LongMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -873,6 +875,19 @@ final class Short128Vector extends ShortVector {
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_128;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Short128Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -889,6 +891,19 @@ final class Short256Vector extends ShortVector {
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_256;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Short256Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -921,6 +923,19 @@ final class Short512Vector extends ShortVector {
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_512;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Short512Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -865,6 +867,19 @@ final class Short64Vector extends ShortVector {
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_64;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final Short64Mask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -859,6 +861,19 @@ final class ShortMaxVector extends ShortVector {
|
||||
.intoArray(a, offset + species.length());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_MAX;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final ShortMaxMask laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,10 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import jdk.internal.vm.annotation.ForceInline;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Objects;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -314,6 +318,52 @@ public abstract class VectorShuffle<E> extends jdk.internal.vm.vector.VectorSupp
|
||||
return vsp.shuffleFromArray(sourceIndexes, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a shuffle from a {@linkplain MemorySegment memory segment}
|
||||
* starting at an offset into the memory segment.
|
||||
* Bytes are composed into shuffle lanes according
|
||||
* to the specified byte order.
|
||||
* The shuffle is arranged into lanes according to
|
||||
* <a href="Vector.html#lane-order">memory ordering</a>.
|
||||
* <p>
|
||||
* The following pseudocode illustrates the behavior:
|
||||
* <pre>{@code
|
||||
* var slice = ms.asSlice(offset);
|
||||
* int[] ar = new int[species.length()];
|
||||
* for (int n = 0; n < ar.length; n++) {
|
||||
* ar[n] = slice.getAtIndex(ValuaLayout.JAVA_INT_UNALIGNED, n);
|
||||
* }
|
||||
* VectorShuffle<E> r = VectorShuffle.fromArray(species, ar, 0);
|
||||
* }</pre>
|
||||
*
|
||||
* @implNote
|
||||
* This operation is likely to be more efficient if
|
||||
* the specified byte order is the same as
|
||||
* {@linkplain ByteOrder#nativeOrder()
|
||||
* the platform native order},
|
||||
* since this method will not need to reorder
|
||||
* the bytes of lane values.
|
||||
*
|
||||
* @param species the shuffle species
|
||||
* @param ms the source indexes in memory which the shuffle will draw from
|
||||
* @param offset the offset into the segment
|
||||
* @param bo the byte order
|
||||
* @param <E> the boxed element type
|
||||
* @return a shuffle where each lane's source index is set to the given
|
||||
* {@code int} value, partially wrapped if exceptional
|
||||
* @throws IndexOutOfBoundsException if {@code offset < 0}, or
|
||||
* {@code offset > sourceIndexes.byteSize() - VLENGTH * 4}
|
||||
* @since 25
|
||||
*/
|
||||
@ForceInline
|
||||
public static final <E> VectorShuffle<E> fromMemorySegment(VectorSpecies<E> species, MemorySegment ms,
|
||||
long offset, ByteOrder bo) {
|
||||
long memsize = species.length() * 4;
|
||||
MemorySegment arraySlice = ms.asSlice(offset, memsize);
|
||||
int[] indices = arraySlice.toArray(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo));
|
||||
return species.shuffleFromArray(indices,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a shuffle for a given species from
|
||||
* the successive values of an operator applied to
|
||||
@ -523,6 +573,45 @@ public abstract class VectorShuffle<E> extends jdk.internal.vm.vector.VectorSupp
|
||||
*/
|
||||
public abstract void intoArray(int[] a, int offset);
|
||||
|
||||
/**
|
||||
* Stores this shuffle into a {@linkplain MemorySegment memory segment}
|
||||
* starting at an offset using explicit byte order.
|
||||
* <p>
|
||||
* Bytes are extracted from shuffle lanes according
|
||||
* to the specified byte ordering.
|
||||
* The shuffle lanes are stored according to their
|
||||
* <a href="Vector.html#lane-order">memory ordering</a>.
|
||||
* <p>
|
||||
* The following pseudocode illustrates the behavior:
|
||||
* <pre>{@code
|
||||
* int[] a = this.toArray();
|
||||
* var slice = ms.asSlice(offset)
|
||||
* for (int n = 0; n < a.length; n++) {
|
||||
* slice.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, n, a[n]);
|
||||
* }
|
||||
* }</pre>
|
||||
*
|
||||
* @implNote
|
||||
* This operation is likely to be more efficient if
|
||||
* the specified byte order is the same as
|
||||
* {@linkplain ByteOrder#nativeOrder()
|
||||
* the platform native order},
|
||||
* since this method will not need to reorder
|
||||
* the bytes of lane values.
|
||||
*
|
||||
* @apiNote Shuffle source indexes are always in the
|
||||
* range from {@code -VLENGTH} to {@code VLENGTH-1}.
|
||||
* @param ms the memory segment
|
||||
* @param offset the offset into the segment
|
||||
* @param bo the byte order
|
||||
* @throws IndexOutOfBoundsException if {@code offset < 0} or
|
||||
* {@code offset > a.byteSize() - this.length() * 4}
|
||||
* @throws IllegalArgumentException if the segment {@code ms} is read-only
|
||||
* @since 25
|
||||
*/
|
||||
public abstract void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo);
|
||||
|
||||
|
||||
/**
|
||||
* Converts this shuffle into a vector, creating a vector
|
||||
* of integral values corresponding to the lane source
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,8 @@
|
||||
package jdk.incubator.vector;
|
||||
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
@ -1213,10 +1215,72 @@ final class $vectortype$ extends $abstractvectortype$ {
|
||||
a[offset + i] = laneSource(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#end[longOrDouble]
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public void intoMemorySegment(MemorySegment ms, long offset, ByteOrder bo) {
|
||||
#if[byte]
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_$BITS$;
|
||||
Vector<Byte> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.B2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 2)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 2, bo);
|
||||
v.convertShape(VectorOperators.B2I, species, 3)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize() * 3, bo);
|
||||
#end[byte]
|
||||
#if[short]
|
||||
VectorSpecies<Integer> species = IntVector.SPECIES_$BITS$;
|
||||
Vector<Short> v = toBitsVector();
|
||||
v.convertShape(VectorOperators.S2I, species, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
v.convertShape(VectorOperators.S2I, species, 1)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset + species.vectorByteSize(), bo);
|
||||
#end[short]
|
||||
#if[intOrFloat]
|
||||
toBitsVector().intoMemorySegment(ms, offset, bo);
|
||||
#end[intOrFloat]
|
||||
#if[longOrDouble]
|
||||
switch (length()) {
|
||||
case 1 -> ms.set(ValueLayout.OfInt.JAVA_INT_UNALIGNED, offset, laneSource(0));
|
||||
case 2 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 4 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 8 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
case 16 -> toBitsVector()
|
||||
.convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0)
|
||||
.reinterpretAsInts()
|
||||
.intoMemorySegment(ms, offset, bo);
|
||||
default -> {
|
||||
VectorIntrinsics.checkFromIndexSize(offset, length(), ms.byteSize() / 4);
|
||||
for (int i = 0; i < length(); i++) {
|
||||
ms.setAtIndex(ValueLayout.JAVA_INT_UNALIGNED, offset + (i << 2), laneSource(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
#end[longOrDouble]
|
||||
}
|
||||
|
||||
@Override
|
||||
@ForceInline
|
||||
public final $masktype$ laneIsValid() {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,6 +21,9 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
import org.testng.annotations.DataProvider;
|
||||
|
||||
import java.lang.foreign.Arena;
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.foreign.ValueLayout;
|
||||
@ -32,28 +35,104 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class AbstractVectorLoadStoreTest extends AbstractVectorTest {
|
||||
|
||||
static final ValueLayout.OfInt SHUFFLE_ELEMENT_LAYOUT = ValueLayout.JAVA_INT.withByteAlignment(1);
|
||||
|
||||
static final Collection<ByteOrder> BYTE_ORDER_VALUES = Set.of(
|
||||
ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
static final List<IntFunction<ByteBuffer>> BYTE_BUFFER_GENERATORS = List.of(
|
||||
withToString("HB:RW:NE", (int s) ->
|
||||
ByteBuffer.allocate(s)
|
||||
.order(ByteOrder.nativeOrder())),
|
||||
withToString("DB:RW:NE", (int s) ->
|
||||
ByteBuffer.allocateDirect(s)
|
||||
.order(ByteOrder.nativeOrder())),
|
||||
withToString("MS:RW:NE", (int s) ->
|
||||
Arena.ofAuto().allocate(s)
|
||||
.asByteBuffer()
|
||||
.order(ByteOrder.nativeOrder())
|
||||
)
|
||||
static final int SHUFFLE_BUFFER_REPS = Integer.getInteger("jdk.incubator.vector.test.buffer-vectors", 25000 / 256);
|
||||
|
||||
static final List<IntFunction<int[]>> SHUFFLE_INT_GENERATORS = List.of(
|
||||
withToString("int[i * 5]", (int s) -> {
|
||||
return fill(s * SHUFFLE_BUFFER_REPS,
|
||||
i -> (int)(i * 5));
|
||||
}),
|
||||
withToString("int[i + 1]", (int s) -> {
|
||||
return fill(s * SHUFFLE_BUFFER_REPS,
|
||||
i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1)));
|
||||
})
|
||||
);
|
||||
|
||||
static final List<IntFunction<MemorySegment>> MEMORY_SEGMENT_GENERATORS = List.of(
|
||||
static final List<IntFunction<Integer>> SHUFFLE_INDEX_GENERATORS = List.of(
|
||||
withToString("-1", (int l) -> {
|
||||
return -1;
|
||||
}),
|
||||
withToString("l", (int l) -> {
|
||||
return l;
|
||||
}),
|
||||
withToString("l - 1", (int l) -> {
|
||||
return l - 1;
|
||||
}),
|
||||
withToString("l + 1", (int l) -> {
|
||||
return l + 1;
|
||||
})
|
||||
);
|
||||
|
||||
// Relative to byte[] array.length or MemorySegment.byteSize()
|
||||
static final List<IntFunction<Integer>> SHUFFLE_BYTE_INDEX_GENERATORS = List.of(
|
||||
withToString("-1", (int l) -> {
|
||||
return -1;
|
||||
}),
|
||||
withToString("l", (int l) -> {
|
||||
return l;
|
||||
}),
|
||||
withToString("l - 1", (int l) -> {
|
||||
return l - 1;
|
||||
}),
|
||||
withToString("l + 1", (int l) -> {
|
||||
return l + 1;
|
||||
})
|
||||
);
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shuffleIntProvider() {
|
||||
return SHUFFLE_INT_GENERATORS.stream()
|
||||
.map(f -> new Object[]{f})
|
||||
.toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shuffleIntProviderForIOOBE() {
|
||||
var f = SHUFFLE_INT_GENERATORS.get(0);
|
||||
return SHUFFLE_INDEX_GENERATORS.stream()
|
||||
.map(fi -> {
|
||||
return new Object[] {f, fi};
|
||||
})
|
||||
.toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shuffleIntMemorySegmentProvider() {
|
||||
return SHUFFLE_INT_GENERATORS.stream().
|
||||
flatMap(fa -> SHUFFLE_MEMORY_SEGMENT_GENERATORS.stream().
|
||||
flatMap(fb -> BYTE_ORDER_VALUES.stream().map(bo -> {
|
||||
return new Object[]{fa, fb, bo};
|
||||
}))).
|
||||
toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] shuffleIntByteProviderForIOOBE() {
|
||||
var f = SHUFFLE_INT_GENERATORS.get(0);
|
||||
return SHUFFLE_BYTE_INDEX_GENERATORS.stream().map(fi -> {
|
||||
return new Object[] {f, fi};
|
||||
}).toArray(Object[][]::new);
|
||||
}
|
||||
|
||||
static MemorySegment toShuffleSegment(VectorSpecies<?> vsp, int[] a, IntFunction<MemorySegment> fb) {
|
||||
MemorySegment ms = fb.apply(a.length * 4);
|
||||
return ms.copyFrom(MemorySegment.ofArray(a));
|
||||
}
|
||||
|
||||
private static final List<IntFunction<MemorySegment>> SHARED_MEMORY_SEGMENT_GENERATORS = List.of(
|
||||
withToString("DMS", (int s) ->
|
||||
Arena.ofAuto().allocate(s)
|
||||
),
|
||||
@ -73,14 +152,6 @@ public class AbstractVectorLoadStoreTest extends AbstractVectorTest {
|
||||
float[] b = new float[s / Float.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
withToString("HMS:long[]", (int s) -> {
|
||||
long[] b = new long[s / Long.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
withToString("HMS:double[]", (int s) -> {
|
||||
double[] b = new double[s / Double.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
withToString("HMS:ByteBuffer.wrap", (int s) -> {
|
||||
byte[] b = new byte[s];
|
||||
ByteBuffer buff = ByteBuffer.wrap(b);
|
||||
@ -100,12 +171,54 @@ public class AbstractVectorLoadStoreTest extends AbstractVectorTest {
|
||||
withToString("HMS:IntBuffer.allocate", (int s) -> {
|
||||
IntBuffer buff = IntBuffer.allocate(s / Integer.BYTES);
|
||||
return MemorySegment.ofBuffer(buff);
|
||||
}),
|
||||
// Slice
|
||||
withToString("HMS:long[].asSlice", (int s) -> {
|
||||
long[] b = new long[s / Long.BYTES + 1];
|
||||
return MemorySegment.ofArray(b).asSlice(Long.BYTES);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
//These tests are adjusted to ensure we allocate enough memory for ints because we're passing
|
||||
//a memory segment size of an int array in bytes, but it's subject to integer division of a longer
|
||||
//array element.
|
||||
static final List<IntFunction<MemorySegment>> SHUFFLE_MEMORY_SEGMENT_GENERATORS = Stream.concat(
|
||||
SHARED_MEMORY_SEGMENT_GENERATORS.stream(),
|
||||
Stream.of(
|
||||
withToString("HMS:long[]:shuffle", (int s) -> {
|
||||
long[] b = new long[(s + Long.BYTES- 1) / Long.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
|
||||
withToString("HMS:double[]:shuffle", (int s) -> {
|
||||
double[] b = new double[(s + Double.BYTES - 1)/ Double.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
// Slice
|
||||
withToString("HMS:long[].asSlice:shuffle", (int s) -> {
|
||||
long[] b = new long[(s + Long.BYTES - 1) / Long.BYTES + 1];
|
||||
return MemorySegment.ofArray(b).asSlice(Long.BYTES);
|
||||
})
|
||||
)
|
||||
).toList();
|
||||
|
||||
static final List<IntFunction<MemorySegment>> MEMORY_SEGMENT_GENERATORS = Stream.concat(
|
||||
SHARED_MEMORY_SEGMENT_GENERATORS.stream(),
|
||||
Stream.of(
|
||||
withToString("HMS:long[]", (int s) -> {
|
||||
long[] b = new long[s / Long.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
withToString("HMS:double[]", (int s) -> {
|
||||
double[] b = new double[s / Double.BYTES];
|
||||
return MemorySegment.ofArray(b);
|
||||
}),
|
||||
// Slice
|
||||
withToString("HMS:long[].asSlice", (int s) -> {
|
||||
long[] b = new long[s / Long.BYTES + 1];
|
||||
return MemorySegment.ofArray(b).asSlice(Long.BYTES);
|
||||
})
|
||||
)
|
||||
).toList();
|
||||
|
||||
private static final int[] fill(int s, IntUnaryOperator f) {
|
||||
return IntStream.range(0, s).map(f).toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -22,19 +22,16 @@
|
||||
*/
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import jdk.incubator.vector.VectorSpecies;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
import org.testng.Assert;
|
||||
@ -227,4 +224,18 @@ public class AbstractVectorTest {
|
||||
Assert.assertEquals(r[i], f.apply(a[i], b[i]), "(" + a[i] + ", " + b[i] + ") at index #" + i);
|
||||
}
|
||||
}
|
||||
|
||||
// Non-optimized test partial wrap derived from the Spec:
|
||||
// Validation function for lane indexes which may be out of the valid range of [0..VLENGTH-1].
|
||||
// The index is forced into this range by adding or subtracting a suitable multiple of VLENGTH.
|
||||
// Specifically, the index is reduced into the required range by computing the value of length-floor, where
|
||||
// floor=vectorSpecies().loopBound(length) is the next lower multiple of VLENGTH.
|
||||
// As long as VLENGTH is a power of two, then the reduced index also equal to index & (VLENGTH - 1).
|
||||
static int testPartiallyWrapIndex(VectorSpecies<?> vsp, int index) {
|
||||
if (index >= 0 && index < vsp.length()) {
|
||||
return index;
|
||||
}
|
||||
int wrapped = Math.floorMod(index, vsp.length());
|
||||
return wrapped - vsp.length();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Byte> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Byte> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ByteVector fromArray(byte[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Byte128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void assertArraysEquals(boolean[] r, byte[] a) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Byte> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Byte> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ByteVector fromArray(byte[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Byte256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void assertArraysEquals(boolean[] r, byte[] a) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Byte> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Byte> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ByteVector fromArray(byte[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Byte512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void assertArraysEquals(boolean[] r, byte[] a) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Byte> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Byte> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ByteVector fromArray(byte[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Byte64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void assertArraysEquals(boolean[] r, byte[] a) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Byte> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Byte> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Byte> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ByteVector fromArray(byte[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class ByteMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Byte> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void assertArraysEquals(boolean[] r, byte[] a) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Double128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Double> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Double> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static DoubleVector fromArray(double[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Double128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Double256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Double> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Double> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static DoubleVector fromArray(double[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Double256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Double512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Double> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Double> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static DoubleVector fromArray(double[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Double512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Double64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Double> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Double> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static DoubleVector fromArray(double[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Double64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Double> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Double> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Double> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static DoubleVector fromArray(double[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class DoubleMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Double> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Float128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Float> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Float> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static FloatVector fromArray(float[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Float128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Float256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Float> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Float> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static FloatVector fromArray(float[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Float256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Float512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Float> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Float> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static FloatVector fromArray(float[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Float512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Float64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Float> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Float> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static FloatVector fromArray(float[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Float64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Float> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Float> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Float> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static FloatVector fromArray(float[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class FloatMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Float> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Int128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Integer> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Integer> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static IntVector fromArray(int[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Int128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Int256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Integer> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Integer> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static IntVector fromArray(int[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Int256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Int512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Integer> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Integer> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static IntVector fromArray(int[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Int512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Int64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Integer> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Integer> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static IntVector fromArray(int[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Int64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Integer> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Integer> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Integer> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static IntVector fromArray(int[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class IntMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Integer> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Long128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Long> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Long> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static LongVector fromArray(long[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Long128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Long256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Long> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Long> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static LongVector fromArray(long[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Long256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Long512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Long> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Long> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static LongVector fromArray(long[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Long512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Long64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Long> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Long> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static LongVector fromArray(long[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Long64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Long> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Long> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Long> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static LongVector fromArray(long[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class LongMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Long> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Short128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Short> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Short> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ShortVector fromArray(short[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Short128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
int i = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Short256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Short> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Short> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ShortVector fromArray(short[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Short256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
int i = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Short512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Short> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Short> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ShortVector fromArray(short[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Short512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
int i = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -249,6 +249,26 @@ public class Short64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Short> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Short> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ShortVector fromArray(short[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -682,18 +702,161 @@ public class Short64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
int i = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -256,6 +256,26 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<Short> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<Short> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<Short> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static ShortVector fromArray(short[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -689,18 +709,161 @@ public class ShortMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<Short> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
int i = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -269,6 +269,26 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest {
|
||||
return a;
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<$Boxtype$> shuffleFromArray(int[] a, int i) {
|
||||
return SPECIES.shuffleFromArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoArray(VectorShuffle<$Boxtype$> s, int[] a, int i) {
|
||||
s.intoArray(a, i);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static VectorShuffle<$Boxtype$> shuffleFromMemorySegment(MemorySegment mem, int i, ByteOrder bo) {
|
||||
return VectorShuffle.fromMemorySegment(SPECIES, mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static void shuffleIntoMemorySegment(VectorShuffle<$Boxtype$> s, MemorySegment mem, int i, ByteOrder bo) {
|
||||
s.intoMemorySegment(mem, i, bo);
|
||||
}
|
||||
|
||||
@DontInline
|
||||
static $abstractvectortype$ fromArray($type$[] a, int i) {
|
||||
// Tests the species method and the equivalent vector method it defers to
|
||||
@ -702,18 +722,161 @@ public class $vectorteststype$ extends AbstractVectorLoadStoreTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
static void loadStoreShuffle() {
|
||||
IntUnaryOperator fn = a -> a + 5;
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
var shuffle = VectorShuffle.fromOp(SPECIES, fn);
|
||||
int [] r = shuffle.toArray();
|
||||
@Test(dataProvider = "shuffleIntProvider")
|
||||
static void loadStoreShuffleArray(IntFunction<int[]> fa) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
int [] a = expectedShuffle(SPECIES.length(), fn);
|
||||
Assert.assertEquals(r, a);
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<$Boxtype$> shuffle = VectorShuffle.fromArray(SPECIES, a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; i++) {
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, a[i]), r[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void storeShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, i);
|
||||
shuffleIntoArray(shuffle, r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, index);
|
||||
shuffleIntoArray(shuffle, r, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntProviderForIOOBE")
|
||||
static void loadShuffleArrayIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
int[] a = fa.apply(SPECIES.length());
|
||||
int[] r = new int[a.length];
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < a.length; i += SPECIES.length()) {
|
||||
VectorShuffle<$Boxtype$> shuffle = shuffleFromArray(a, i);
|
||||
shuffle.intoArray(r, i);
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply(a.length);
|
||||
boolean shouldFail = isIndexOutOfBounds(SPECIES.length(), index, a.length);
|
||||
try {
|
||||
shuffleFromArray(a, index);
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntMemorySegmentProvider")
|
||||
static void loadStoreShuffleMemorySegment(IntFunction<int[]> fa,
|
||||
IntFunction<MemorySegment> fb,
|
||||
ByteOrder bo) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), fb);
|
||||
MemorySegment r = fb.apply((int) a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4; //An integer for every lane is read out. So 4 bytes per lane
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<$Boxtype$> shuffle = VectorShuffle.fromMemorySegment(SPECIES, a, i, bo);
|
||||
shuffle.intoMemorySegment(r, i, bo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < l / 4; i++) {
|
||||
int ai = a.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
int ri = r.getAtIndex(ValueLayout.JAVA_INT_UNALIGNED.withOrder(bo), i);
|
||||
Assert.assertEquals(testPartiallyWrapIndex(SPECIES, ai), ri);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleLoadMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<$Boxtype$> shuffle = shuffleFromMemorySegment(a, i, ByteOrder.nativeOrder());
|
||||
shuffle.intoMemorySegment(r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
shuffleFromMemorySegment(a, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dataProvider = "shuffleIntByteProviderForIOOBE")
|
||||
static void shuffleStoreMemorySegmentIOOBE(IntFunction<int[]> fa, IntFunction<Integer> fi) {
|
||||
MemorySegment a = toShuffleSegment(SPECIES, fa.apply(SPECIES.length()), i -> Arena.ofAuto().allocate(i));
|
||||
MemorySegment r = Arena.ofAuto().allocate(a.byteSize());
|
||||
|
||||
int l = (int) a.byteSize();
|
||||
int s = SPECIES.length() * 4;
|
||||
|
||||
for (int ic = 0; ic < INVOC_COUNT; ic++) {
|
||||
for (int i = 0; i < l; i += s) {
|
||||
VectorShuffle<$Boxtype$> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, i, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, i, ByteOrder.nativeOrder());
|
||||
}
|
||||
}
|
||||
|
||||
int index = fi.apply((int) a.byteSize());
|
||||
boolean shouldFail = isIndexOutOfBounds(s, index, (int) a.byteSize());
|
||||
try {
|
||||
VectorShuffle<$Boxtype$> shuffle =
|
||||
VectorShuffle.fromMemorySegment(SPECIES, a, 0, ByteOrder.nativeOrder());
|
||||
shuffleIntoMemorySegment(shuffle, r, index, ByteOrder.nativeOrder());
|
||||
if (shouldFail) {
|
||||
Assert.fail("Failed to throw IndexOutOfBoundsException");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (!shouldFail) {
|
||||
Assert.fail("Unexpected IndexOutOfBoundsException");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if[short]
|
||||
static void assertArraysEquals(char[] a, char[] r, boolean[] mask) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user