Skip to content

Commit

Permalink
Test all supported vector widths (#25)
Browse files Browse the repository at this point in the history
* test both vector species if on 512-bit-capable platform

* test both species on all platforms
  • Loading branch information
steveatgh authored Sep 19, 2023
1 parent 6b398c3 commit 6772c98
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
24 changes: 22 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import me.champeau.jmh.JmhBytecodeGeneratorTask
import org.gradle.internal.os.OperatingSystem
import org.ajoberstar.grgit.Grgit
import java.time.Duration
import jdk.incubator.vector.ByteVector

plugins {
id 'java'
Expand Down Expand Up @@ -69,18 +70,37 @@ tasks.register('downloadTestData') {
}
}

test {
tasks.register('test256', Test) {
dependsOn downloadTestData
useJUnitPlatform()
jvmArgs += [
'--add-modules', 'jdk.incubator.vector',
'-Xmx2g',
'-Dorg.simdjson.species=256'
]
testLogging {
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
}
}

tasks.register('test512', Test) {
dependsOn downloadTestData
useJUnitPlatform()
jvmArgs += [
'--add-modules', 'jdk.incubator.vector',
'-Xmx2g'
'-Xmx2g',
'-Dorg.simdjson.species=512'
]
testLogging {
events 'PASSED', 'SKIPPED', 'FAILED', 'STANDARD_OUT', 'STANDARD_ERROR'
}
}

test {
dependsOn 'test256'
dependsOn 'test512'
}

tasks.withType(JmhBytecodeGeneratorTask).configureEach {
jvmArgs.set(["--add-modules=jdk.incubator.vector"])
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.jvmargs="--add-modules=jdk.incubator.vector"
8 changes: 7 additions & 1 deletion src/main/java/org/simdjson/StructuralIndexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ class StructuralIndexer {
static final int N_CHUNKS;

static {
SPECIES = ByteVector.SPECIES_PREFERRED;
String species = System.getProperty("org.simdjson.species", "preferred");
SPECIES = switch(species) {
case "preferred" -> ByteVector.SPECIES_PREFERRED;
case "512" -> ByteVector.SPECIES_512;
case "256" -> ByteVector.SPECIES_256;
default -> throw new IllegalArgumentException("Unsupported vector species: " + species);
};
N_CHUNKS = 64 / SPECIES.vectorByteSize();
if (SPECIES != ByteVector.SPECIES_256 && SPECIES != ByteVector.SPECIES_512) {
throw new IllegalArgumentException("Unsupported vector species: " + SPECIES);
Expand Down

0 comments on commit 6772c98

Please sign in to comment.