[openjdk] Vector API

目录

 

一、SIMD today

1.1 x86: MMX, SSE, AVX, AVX2, AVX-512

1.2 ARM: NEON, SVE, SVE2

1.3 POWER: VMX/AltiVec

1.4 MIPS: MSA LASX

二、JVM and SIMD today

2.1 Automatic vectorization of Java code

2.2  JVM intrinsics

2.3 Vector API


一、SIMD today

1.1 x86: MMX, SSE, AVX, AVX2, AVX-512

8 64-bit registers (MMX) to 32 512-bit registers (AVX-512)

1.2 ARM: NEON, SVE, SVE2

32 128-bit registers (NEON) to 32 128-2048-bit in SVE

1.3 POWER: VMX/AltiVec

32 128-bit registers

1.4 MIPS: MSA LASX

32 128-bit registers in  32 128-bit registers in  LASX(only Loongson expand)

 

二、JVM and SIMD today

2.1 Automatic vectorization of Java code

Superword optimizations (-XX:+UseSuperWord)in HotSpot C2 compiler to derive SIMD code from sequential code.

缺点:And applied only to unrolled loops. Superword optimizations can be very brittle doesn’t (and can’t) cover all the use cases.

2.2  JVM intrinsics

e.g., Array copying, filling, and comparison

缺点:Intrinsics are point fixes, not general powerful, lightweight, and flexible high development costs

2.3 Vector API

JEP 338: “Vector API (Incubator)”

reliable way to write performant vectorized code.

int[] A, B, C
for (int i = 0; i < MAX; i++) {
A[i] = B[i] + C[i];
}

equal:

var S = IntVector.SPECIES_PREFERRED;
for (int i = 0; i < MAX; i += S.length()) {
var va = IntVector.fromArray(S, A, i);
var vb = IntVector.fromArray(S, B, i);
var vc = va.add(vb);
vc.intoArray(C, i);
}


 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海棠花败

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值