diff --git a/build.gradle b/build.gradle index 7a04bad..c88fd88 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/src/main/java/org/simdjson/StructuralIndexer.java b/src/main/java/org/simdjson/StructuralIndexer.java index cb0201e..c0eb4b0 100644 --- a/src/main/java/org/simdjson/StructuralIndexer.java +++ b/src/main/java/org/simdjson/StructuralIndexer.java @@ -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);