Skip to content

Commit 6772c98

Browse files
authored
Test all supported vector widths (simdjson#25)
* test both vector species if on 512-bit-capable platform * test both species on all platforms
1 parent 6b398c3 commit 6772c98

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

build.gradle

+22-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import me.champeau.jmh.JmhBytecodeGeneratorTask
22
import org.gradle.internal.os.OperatingSystem
33
import org.ajoberstar.grgit.Grgit
44
import java.time.Duration
5+
import jdk.incubator.vector.ByteVector
56

67
plugins {
78
id 'java'
@@ -69,18 +70,37 @@ tasks.register('downloadTestData') {
6970
}
7071
}
7172

72-
test {
73+
tasks.register('test256', Test) {
74+
dependsOn downloadTestData
75+
useJUnitPlatform()
76+
jvmArgs += [
77+
'--add-modules', 'jdk.incubator.vector',
78+
'-Xmx2g',
79+
'-Dorg.simdjson.species=256'
80+
]
81+
testLogging {
82+
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
83+
}
84+
}
85+
86+
tasks.register('test512', Test) {
7387
dependsOn downloadTestData
7488
useJUnitPlatform()
7589
jvmArgs += [
7690
'--add-modules', 'jdk.incubator.vector',
77-
'-Xmx2g'
91+
'-Xmx2g',
92+
'-Dorg.simdjson.species=512'
7893
]
7994
testLogging {
8095
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
8196
}
8297
}
8398

99+
test {
100+
dependsOn 'test256'
101+
dependsOn 'test512'
102+
}
103+
84104
tasks.withType(JmhBytecodeGeneratorTask).configureEach {
85105
jvmArgs.set(["--add-modules=jdk.incubator.vector"])
86106
}

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs="--add-modules=jdk.incubator.vector"

src/main/java/org/simdjson/StructuralIndexer.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ class StructuralIndexer {
1212
static final int N_CHUNKS;
1313

1414
static {
15-
SPECIES = ByteVector.SPECIES_PREFERRED;
15+
String species = System.getProperty("org.simdjson.species", "preferred");
16+
SPECIES = switch(species) {
17+
case "preferred" -> ByteVector.SPECIES_PREFERRED;
18+
case "512" -> ByteVector.SPECIES_512;
19+
case "256" -> ByteVector.SPECIES_256;
20+
default -> throw new IllegalArgumentException("Unsupported vector species: " + species);
21+
};
1622
N_CHUNKS = 64 / SPECIES.vectorByteSize();
1723
if (SPECIES != ByteVector.SPECIES_256 && SPECIES != ByteVector.SPECIES_512) {
1824
throw new IllegalArgumentException("Unsupported vector species: " + SPECIES);

0 commit comments

Comments
 (0)