Skip to content

Instantly share code, notes, and snippets.

@justADeni
Created November 29, 2025 03:41
Show Gist options
  • Select an option

  • Save justADeni/8fbf04371f06cfbf2a5c83cb7e77a68b to your computer and use it in GitHub Desktop.

Select an option

Save justADeni/8fbf04371f06cfbf2a5c83cb7e77a68b to your computer and use it in GitHub Desktop.
Util method for getting the right species size when working with Java Vector API
import jdk.incubator.vector.VectorShape;
import jdk.incubator.vector.VectorSpecies;
private static <T> VectorSpecies<T> findSpecies(Class<?> type, int amount) {
int bitsize = VectorSpecies.elementSize(type) * amount;
VectorShape vectorShape = VectorShape.forBitSize(bitsize);
return (VectorSpecies<T>) VectorSpecies.of(type, vectorShape);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment