AugustNagro / utf8.java

Vectorized UTF-8 Validation for Java
62 stars 7 forks source link

java.lang.NoClassDefFoundError: jdk/incubator/vector/Vector #2

Closed LifeIsStrange closed 3 years ago

LifeIsStrange commented 3 years ago

Hi, I'm trying to learn the Java Vector api in general (nothing to do with this repository) and I can't build projects with the API..

Either with gradle or maven and even by cloning your project (and downgrading the jdk to version 16) I always end up with this error: java.lang.NoClassDefFoundError: jdk/incubator/vector/Vector

WHY ?

@AugustNagro

AugustNagro commented 3 years ago

Are you enabling preview features and the incubator module? Also Graal JVM or OpenJDK?

java --enable-preview --add-modules jdk.incubator.vector

On Wed, Mar 17, 2021, 9:20 PM LifeIsStrange @.***> wrote:

Hi, I'm trying to learn the Java Vector api in general (nothing to do with this repository) and I can't build projects with the API..

Either with gradle or maven and even by cloning your project (and downgrading the jdk to version 16) I always end up with this error: java.lang.NoClassDefFoundError: jdk/incubator/vector/Vector

WHY ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AugustNagro/utf8.java/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQOKNVKXT77KKF3FUMMDHLTEF5PXANCNFSM4ZL3FIWQ .

LifeIsStrange commented 3 years ago

Hi, thanks for the help. Those flags are already included, the issue is that Intellij 2021.1 beta seems to not support the vector api. Running from the command line works fine (OpenJDK).

BTW I have another question, feel free to not answer ! So I am currently translating a C# SIMD implementation and it has Sse3.HorizontalAdd(sum, sum); -> __m128d _mm_hadd_pd (m128d a, m128d b) I don't understand the difference between a regular add and an horizontal add but more importantly I can't find a similar method in the Vector API, how to efficiently achieve an horizontal add with the Vector API ? Again feel free to not answer, this is more for stackoverflow

AugustNagro commented 3 years ago

Nice. I can run in IDEA, but you have to configure the project properties to include the incubator module. You can even debug with IDEA, which is great.

Sorry I don't know what horizontal addition even means. I wouldn't be surprised if the api does not support a lot of the esoteric simd apis. But maybe you can emulate the behavior with bitwise ops?

On Tue, Mar 23, 2021, 4:32 PM LifeIsStrange @.***> wrote:

Hi, thanks for the help. Those flags are already included, the issue is that Intellij 2021.1 beta seems to not support the vector api. Running from the command line works fine (OpenJDK).

BTW I have another question, feel free to not answer ! So I am currently translating a C# SIMD implementation and it has Sse3.HorizontalAdd(sum, sum); -> __m128d _mm_hadd_pd (m128d a, m128d b) I don't understand the difference between a regular add and an horizontal add but more importantly I can't find a similar method in the Vector API, how to efficiently achieve an horizontal add with the Vector API ? Again feel free to not answer, this is more for stackoverflow

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AugustNagro/utf8.java/issues/2#issuecomment-805348970, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQOKNV66QZC3DF5PIREHJDTFEQHHANCNFSM4ZL3FIWQ .

lemire commented 3 years ago

If take two vectors and add them component-by-component, it is viewed as "vertical".

Horizontal means, in this instance, that you add successive elements together (pairwise).

I do not know anything about the Vector API but if it lacks support for pairwise addition, it is a serious limitation.

AugustNagro commented 3 years ago

Thanks for the info @lemire

I do not see it in the VectorOperators javadoc.

The devs are planning to add unsigned & saturating arithmetic; the best thing to do is bring it up on the panama-dev mailing list. In my experience they are very helpful. And lots of people have been sharing their jdk.incubator.vector creations on this list, which is cool to see & get inspired!

lemire commented 3 years ago

@AugustNagro I have only spent 3 minutes on it, but there are reduce operations which might get you there.

LifeIsStrange commented 3 years ago

@lemire exactly, I ended up doing a reducelanes of ADD where I specify a bitmask for only adding the adjacents elements that I want. However I find it accidentally less efficient as I was allocating the bitmask at each iteration of a for loop. Moving it out of the loop and reusing it solve most of the performance but I wonder if calling a hadd intrinsic would still be faster. I'm gonna close this "issue" but we can still comment on it.

AugustNagro commented 3 years ago

I don't think VectorOperators.HADD op is needed since reduceLanes(ADD, myMask) should intrinsify to that instruction (or something with the same behavior).

I knew about reduceLanes.. but as you can tell, I still have minimal knowledge of the intel instructions without looking them up!