如何在Java中使用Intel AVX? [英] How to use the Intel AVX in Java?
问题描述
如何使用Java中的Intel AVX向量指令集?这是一个简单的问题,但答案似乎很难找到.
据我所知,大多数当前的Java JVM JITter不支持自动矢量化,或者只是为了非常简单的循环而这样做,所以您很不走运./p>
在Mono的.NET实现中,有Mono.Simd
用于手动矢量代码发射,然后后来MS引入了System.Numeric.Vectors
.不幸的是,Java中没有类似的东西.我不知道Java的向量类是否使用SIMD进行向量化,但我认为它不是.
如果要使用特定于CPU的功能(例如AVX),则唯一的选择是JNI.用C或C ++编写瓶颈部分,然后从Java调用它
Scala的另一种解决方案是使用矢量化代码而不修改您可以在我们如何使JVM快40倍
更新:
现在,正在开发一种新的Vector API,用于手动编写矢量代码
提供孵化器模块jdk.incubator.vector的初始迭代,以表达向量计算,该向量计算在运行时可靠地编译为支持的CPU架构上的最佳向量硬件指令,从而实现优于同等标量计算的性能.
- 用于Java的Vector API开发人员计划*软件
- 任何JVM的JIT编译器是否生成使用矢量化浮点指令的代码?
- Java中的SIMD向量/矩阵?
- OpenJDK中自动矢量化的状态是什么?
- Java中的矢量化算法
How do I use the Intel AVX vector instruction set from Java? It's a simple question but the answer seems to be hard to find.
As I know, most current Java JVM JITters don't support automatic vectorization or just do that for very simple loops, so you're out of luck.
In Mono's .NET implementation there's Mono.Simd
for manual vector code emission and then later MS introduced the System.Numeric.Vectors
. Unfortunately there's nothing similar in Java. I don't know if Java's vector class is vectorized using SIMD or not but I don't think it is.
If you want to use CPU-specific features like AVX then your only choice is JNI. Write your bottle neck part in C or C++ and call it from Java
There's another solution by Scala to use vectorized code without modifying the JVM that you can read in How we made the JVM 40x faster
Update:
Now there's a new Vector API being developed for writing vector code manually
Provide an initial iteration of an incubator module, jdk.incubator.vector, to express vector computations that reliably compile at runtime to optimal vector hardware instructions on supported CPU architectures and thus achieve superior performance to equivalent scalar computations.
- Vector API Developer Program for Java* Software
- Oracle and Intel seek to build a Java API for SIMD support
Read more:
- Do any JVM's JIT compilers generate code that uses vectorized floating point instructions?
- SIMD Vectors/Matrices in Java?
- What is the state of auto-vectorization in OpenJDK?
- Vectorized Algorithms in Java
这篇关于如何在Java中使用Intel AVX?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!