[vector] `fma()` for scalar does not work well

kishida naoki naokikishida at gmail.com
Wed Aug 21 02:19:00 UTC 2019


I'm trying Vector API.
It seems fma() for a scala do not work well both on DoubleVector and
FloatVector.

jshell> var SP = DoubleVector.SPECIES_256
SP ==> Species[double, 4, S_256_BIT]
jshell> var d4 = DoubleVector.fromValues(SP, 1, 2, 3, 4)
d4 ==> [1.0, 2.0, 3.0, 4.0]
jshell> d4.fma(2, 3)
$4 ==> [4.0, 6.0, 8.0, 10.0] // should be [5.0, 7.0, 9.0, 11.0]

For a vector works well.
jshell> var d4b = DoubleVector.single(SP,2)
d4b ==> [2.0, 0.0, 0.0, 0.0]
jshell> var d4c = DoubleVector.single(SP,3)
d4c ==> [3.0, 0.0, 0.0, 0.0]
jshell> d4.fma(d4b, d4c)
$7 ==> [5.0, 0.0, 0.0, 0.0]

Should the former `e1` on the line be `e2`?
  return lanewise(op, broadcast(e1), broadcast(e1));

http://hg.openjdk.java.net/panama/dev/file/395d3f55e3e0/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java#l930

FroatVector is same as it.
-- 
Naoki Kishida
LINE Corp.


More information about the panama-dev mailing list