Slow Vectors?

Mark Hammons markehammons at gmail.com
Thu Jun 3 15:51:29 UTC 2021


Hi all,

I tried testing the incubator vector api today with the following code in
JMH

val panamaIntVecAdder = (a: Array[Int], b: Array[Int]) => {
> var i = 0
> val nArr = Array.ofDim[Int](a.size)
> val species = IntVector.SPECIES_PREFERRED
> while i < a.size do
> val m = species.indexInRange(i, a.length)
> val va = IntVector.fromArray(species, a, i, m)
> val vb = IntVector.fromArray(species, b, i, m)
>
> va.add(vb).intoArray(nArr, i, m)
> i += species.length
> ArraySeq.unsafeWrapArray(nArr)
> }
>

It works, but it's very slow, averaging about  154.038 ns/op. The
simplistic vector addition implementation I wrote beats it very easily,
which I found very suprising. My current jdk is # VM version: JDK 16.0.1,
OpenJDK 64-Bit Server VM, 16.0.1+9-24.

Any idea what I'm doing wrong here?


More information about the panama-dev mailing list