Created
November 29, 2025 03:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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