lessthanoptimal / VectorPerformance

22 stars 1 forks source link

Build failed package jdk.incubator.vector is not visible #1

Open LifeIsStrange opened 3 years ago

LifeIsStrange commented 3 years ago
java: package jdk.incubator.vector is not visible
  (package jdk.incubator.vector is declared in module jdk.incubator.vector, which is not in the module graph)
/home/stephane/dev/VectorPerformance/src/main/java/benchmark/MatrixMultiplication.java:4:21
java: package jdk.incubator.vector is not visible
  (package jdk.incubator.vector is declared in module jdk.incubator.vector, which is not in the module graph) 

I am on intellij Idea 2021.1 beta (latest EAP) and use the openjdk 16 provided by intellij. What should I do ? @lessthanoptimal

lessthanoptimal commented 3 years ago

Recommendation: Use the command line to run the code and IntelliJ to edit it.

IntelliJ is still catching up with all the recent changes to Gradle and maybe the JDK too. I've created one issue here: https://youtrack.jetbrains.com/issue/IDEA-264713

I'm crossing my fingers that the next update to IntelliJ will fix these problems.

LifeIsStrange commented 3 years ago

Thanks for the advice. I'm on archlinux which is still on openjdk 15... I'll try with SDKman

HullBend commented 3 years ago

I'm on archlinux which is still on openjdk 15... I'll try with SDKman

Try yay java-openjdk-ea-bin if your happy with the Arch User Repository. That will give give you the current early access version of Java 17.

LifeIsStrange commented 3 years ago

While I'm with you guys I have another (off-topic) question, feel free to not answer ! So I'm a noob at SIMD and I struggle to understand the difference between Sse2.Add(sum, sum); -> m128d _mm_add_pd (m128d a, m128d b) and Sse3.HorizontalAdd(sum, sum); -> __m128d _mm_hadd_pd (m128d a, __m128d b) It's from the C# API Their documentation is inexistant and only redirect to the x86 intrinsics.

The equivalent of Sse2.Add should be https://download.java.net/java/early_access/jdk16/docs/api/jdk.incubator.vector/jdk/incubator/vector/DoubleVector.html#add(jdk.incubator.vector.Vector) However what is an horizontal Add and how to reproduce an horizontal add with the jdk vector API ?

Intel says :

Horizontally add adjacent pairs of double-precision (64-bit) floating-point elements in a and b, and pack the results in dst.

Whats the difference with "Adds this vector to a second input vector. This is a lane-wise binary operation which applies the primitive addition operation (+) to each pair of corresponding lane values." ?

jiangjiguang commented 2 years ago

I have the same problem, and solved.

In my view, when build, idea uses package is not visible, and you have to set compile args:

org.apache.maven.plugins maven-compiler-plugin 17 17 --add-exports=java.base/sun.net.util=ALL-UNNAMED --add-exports=java.management/sun.management=ALL-UNNAMED --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED --add-exports=java.security.jgss/sun.security.krb5=ALL-UNNAMED --add-modules=jdk.incubator.vector
jiangjiguang commented 2 years ago

image

Mikhail42 commented 2 years ago

Cool, thanks. In my case, I add options to both pom.xml and Idea run configuration (modify options -- add VM options), make Idea mvn reload, and run code from Idea.

The main surprise is that vector computation was much (20x) slow in my case )

I take example from https://openjdk.org/jeps/426, and replace float to double, array size was 10k and 100k