Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ bstats = "3.2.1"
sparsebitset = "1.3"
parallelgzip = "1.0.5"
adventure = "5.2.0"
checkerqual = "4.3.1"
checkerqual = "4.4.0"
truezip = "6.8.4"
auto-value = "1.11.1"
jsr305 = "3.0.2"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.1-all.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
Expand Down
52 changes: 41 additions & 11 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions worldedit-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dependencies {

tasks.test {
maxHeapSize = "1G"
jvmArgs("--add-modules=jdk.incubator.vector")
}

tasks.compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import jdk.incubator.vector.ShortVector;
import jdk.incubator.vector.VectorMask;
import jdk.incubator.vector.VectorOperators;
import jdk.incubator.vector.VectorSpecies;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -109,6 +110,18 @@ private static VectorizedMask vectorizedTargetMaskInverse(char ordinal) {
};
}

/**
* {@return a vector with all lanes set to the given unsigned value}
*
* @param species the species to use
* @param value the value, e.g. a block state ordinal
*/
static ShortVector broadcast(VectorSpecies<Short> species, char value) {
// There is no broadcast(char): a char widens to long, and broadcast(long) rejects values above Short.MAX_VALUE.
// The short cast keeps the bit pattern, so reading the lanes back as chars yields the original value.
return ShortVector.broadcast(species, (short) value);
}

private static final class VectorizedPattern<T extends Filter> extends DelegateFilter<T> implements VectorizedFilter {

private final char ordinal;
Expand All @@ -127,7 +140,7 @@ public Filter newInstance(final Filter other) {
public void applyVector(final VectorFacade get, final VectorFacade set, final VectorMask<Short> mask) {
ShortVector s = set.getOrZero(mask.vectorSpecies());
// only change the lanes the mask dictates us to change, keep the rest
s = s.blend(ShortVector.broadcast(ShortVector.SPECIES_PREFERRED, ordinal), mask);
s = s.blend(broadcast(mask.vectorSpecies(), ordinal), mask);
set.setOrIgnore(s);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.fastasyncworldedit.core.internal.simd;

import jdk.incubator.vector.ShortVector;
import jdk.incubator.vector.VectorSpecies;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertEquals;

class SimdSupportTest {

private static final VectorSpecies<Short> SPECIES = ShortVector.SPECIES_PREFERRED;

@ParameterizedTest
@ValueSource(ints = {0, 1, Short.MAX_VALUE, Short.MAX_VALUE + 1, 34825, Character.MAX_VALUE})
void broadcastChar(int value) {
char[] data = new char[SPECIES.length()];
SimdSupport.broadcast(SPECIES, (char) value).intoCharArray(data, 0);

char[] expected = new char[SPECIES.length()];
Arrays.fill(expected, (char) value);
assertEquals(new String(expected), new String(data));
}

}