JuliaSIMD / JuliaSIMD/LoopVectorization.jl

Multiply 2 16-bit integers and accumulate to 32-bit integer

Open
#37 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
789
Forks
73
PR merge metrics
No merged PRs in 30d

Description

How would I multiply 2 16-bit integers and accumulate to 32-bit integer? Something like `_mm_madd_epi16`
So far the result of the multiplication seems to be done in 16-bit:
```julia
a = Int16.([1 << 8, 1 << 9, 1 << 10, 1 << 10])
b = Int16.([1 << 7, 1 << 8, 1 << 11, 1 << 10])
function fma_avx(a, b)
res = Int32(0)
@avx for i = 1:4
res = res + a[i] * b[i]
end
res
end
```
```julia
julia> fma_avx(a, b)
-32768

julia> fma_avx(Int32.(a), Int32.(b))
3309568
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.