mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-17 10:20:33 +00:00
8376794: Enable copy and mismatch Partial Inlining for AMD AVX512 targets
Reviewed-by: sviswanathan, thartmann
This commit is contained in:
parent
5868d351e2
commit
6abb29cc07
@ -1659,41 +1659,40 @@ void VM_Version::get_processor_features() {
|
||||
if (FLAG_IS_DEFAULT(AllocatePrefetchInstr) && supports_3dnow_prefetch()) {
|
||||
FLAG_SET_DEFAULT(AllocatePrefetchInstr, 3);
|
||||
}
|
||||
#ifdef COMPILER2
|
||||
if (UseAVX > 2) {
|
||||
if (FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize) ||
|
||||
(!FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize) &&
|
||||
ArrayOperationPartialInlineSize != 0 &&
|
||||
ArrayOperationPartialInlineSize != 16 &&
|
||||
ArrayOperationPartialInlineSize != 32 &&
|
||||
ArrayOperationPartialInlineSize != 64)) {
|
||||
int inline_size = 0;
|
||||
if (MaxVectorSize >= 64 && AVX3Threshold == 0) {
|
||||
inline_size = 64;
|
||||
} else if (MaxVectorSize >= 32) {
|
||||
inline_size = 32;
|
||||
} else if (MaxVectorSize >= 16) {
|
||||
inline_size = 16;
|
||||
}
|
||||
if(!FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize)) {
|
||||
warning("Setting ArrayOperationPartialInlineSize as %d", inline_size);
|
||||
}
|
||||
ArrayOperationPartialInlineSize = inline_size;
|
||||
}
|
||||
|
||||
if (ArrayOperationPartialInlineSize > MaxVectorSize) {
|
||||
ArrayOperationPartialInlineSize = MaxVectorSize >= 16 ? MaxVectorSize : 0;
|
||||
if (ArrayOperationPartialInlineSize) {
|
||||
warning("Setting ArrayOperationPartialInlineSize as MaxVectorSize=%zd", MaxVectorSize);
|
||||
} else {
|
||||
warning("Setting ArrayOperationPartialInlineSize as %zd", ArrayOperationPartialInlineSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef COMPILER2
|
||||
if (UseAVX > 2) {
|
||||
if (FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize) ||
|
||||
(!FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize) &&
|
||||
ArrayOperationPartialInlineSize != 0 &&
|
||||
ArrayOperationPartialInlineSize != 16 &&
|
||||
ArrayOperationPartialInlineSize != 32 &&
|
||||
ArrayOperationPartialInlineSize != 64)) {
|
||||
int inline_size = 0;
|
||||
if (MaxVectorSize >= 64 && AVX3Threshold == 0) {
|
||||
inline_size = 64;
|
||||
} else if (MaxVectorSize >= 32) {
|
||||
inline_size = 32;
|
||||
} else if (MaxVectorSize >= 16) {
|
||||
inline_size = 16;
|
||||
}
|
||||
if(!FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize)) {
|
||||
warning("Setting ArrayOperationPartialInlineSize as %d", inline_size);
|
||||
}
|
||||
ArrayOperationPartialInlineSize = inline_size;
|
||||
}
|
||||
|
||||
if (ArrayOperationPartialInlineSize > MaxVectorSize) {
|
||||
ArrayOperationPartialInlineSize = MaxVectorSize >= 16 ? MaxVectorSize : 0;
|
||||
if (ArrayOperationPartialInlineSize) {
|
||||
warning("Setting ArrayOperationPartialInlineSize as MaxVectorSize=%zd", MaxVectorSize);
|
||||
} else {
|
||||
warning("Setting ArrayOperationPartialInlineSize as %zd", ArrayOperationPartialInlineSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAG_IS_DEFAULT(OptimizeFill)) {
|
||||
if (MaxVectorSize < 32 || (!EnableX86ECoreOpts && !VM_Version::supports_avx512vlbw())) {
|
||||
OptimizeFill = false;
|
||||
|
||||
@ -26,6 +26,7 @@ package org.openjdk.bench.jdk.incubator.vector;
|
||||
|
||||
|
||||
import jdk.incubator.vector.ByteVector;
|
||||
import jdk.incubator.vector.ShortVector;
|
||||
import jdk.incubator.vector.DoubleVector;
|
||||
import jdk.incubator.vector.IntVector;
|
||||
import jdk.incubator.vector.LongVector;
|
||||
@ -59,6 +60,9 @@ public class ArrayMismatchBenchmark {
|
||||
byte[] byteData1;
|
||||
byte[] byteData2;
|
||||
|
||||
short[] shortData1;
|
||||
short[] shortData2;
|
||||
|
||||
int[] intData1;
|
||||
int[] intData2;
|
||||
|
||||
@ -69,6 +73,7 @@ public class ArrayMismatchBenchmark {
|
||||
double[] doubleData2;
|
||||
|
||||
static final VectorSpecies<Byte> BYTE_SPECIES_PREFERRED = ByteVector.SPECIES_PREFERRED;
|
||||
static final VectorSpecies<Short> SHORT_SPECIES_PREFERRED = ShortVector.SPECIES_PREFERRED;
|
||||
static final VectorSpecies<Integer> INT_SPECIES_PREFERRED = IntVector.SPECIES_PREFERRED;
|
||||
static final VectorSpecies<Double> FLOAT_SPECIES_PREFERRED = DoubleVector.SPECIES_PREFERRED;
|
||||
static final VectorSpecies<Long> LONG_SPECIES_PREFERRED = LongVector.SPECIES_PREFERRED;
|
||||
@ -89,6 +94,16 @@ public class ArrayMismatchBenchmark {
|
||||
|
||||
System.arraycopy(commonBytes, 0, byteData1, 0, common);
|
||||
System.arraycopy(commonBytes, 0, byteData2, 0, common);
|
||||
} else if (params.getBenchmark().endsWith("Short")) {
|
||||
shortData1 = new short[size];
|
||||
shortData2 = new short[size];
|
||||
Arrays.fill(shortData1, (short)random.nextInt());
|
||||
Arrays.fill(shortData2, (short)random.nextInt());
|
||||
|
||||
short[] commonShorts = new short[common];
|
||||
Arrays.fill(commonShorts, (short)random.nextInt());
|
||||
System.arraycopy(commonShorts, 0, shortData1, 0, common);
|
||||
System.arraycopy(commonShorts, 0, shortData2, 0, common);
|
||||
} else if (params.getBenchmark().endsWith("Int")) {
|
||||
intData1 = random.ints(size).toArray();
|
||||
intData2 = random.ints(size).toArray();
|
||||
@ -141,6 +156,34 @@ public class ArrayMismatchBenchmark {
|
||||
return mismatch;
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int mismatchIntrinsicShort() {
|
||||
return Arrays.mismatch(shortData1, shortData2);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int mismatchVectorShort() {
|
||||
int length = Math.min(shortData1.length, shortData2.length);
|
||||
int index = 0;
|
||||
for (; index < SHORT_SPECIES_PREFERRED.loopBound(length); index += SHORT_SPECIES_PREFERRED.length()) {
|
||||
ShortVector vector1 = ShortVector.fromArray(SHORT_SPECIES_PREFERRED, shortData1, index);
|
||||
ShortVector vector2 = ShortVector.fromArray(SHORT_SPECIES_PREFERRED, shortData2, index);
|
||||
VectorMask<Short> mask = vector1.compare(VectorOperators.NE, vector2);
|
||||
if (mask.anyTrue()) {
|
||||
return index + mask.firstTrue();
|
||||
}
|
||||
}
|
||||
// process the tail
|
||||
int mismatch = -1;
|
||||
for (int i = index; i < length; ++i) {
|
||||
if (shortData1[i] != shortData2[i]) {
|
||||
mismatch = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mismatch;
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int mismatchIntrinsicInt() {
|
||||
return Arrays.mismatch(intData1, intData2);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user