Skip to content

Commit

Permalink
test both species on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
steveatgh committed Sep 18, 2023
1 parent f951683 commit 61ecf96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
17 changes: 9 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,34 +70,35 @@ tasks.register('downloadTestData') {
}
}

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

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

test {
dependsOn 'testPreferred'
dependsOn 'test256'
dependsOn 'test512'
}

tasks.withType(JmhBytecodeGeneratorTask).configureEach {
Expand Down
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 61ecf96

Please sign in to comment.