JuliaSIMD / JuliaSIMD/LoopVectorization.jl

vmap gives incorrect results for iszero

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

Description

If I run vmap with certain functions i get wrong results in some cases. I noticed this first for an integer array with iszero:
```
a = rand(Int8,200,20)
@test map(iszero,a) == vmap(iszero,a) #fails

```
Repeated evaluations of `vmap(iszero,a)` give different answers each time.
The same happens for some other functions I tested such as:

```
a = rand(200,20) #also for floats
vmap( ==(2.0), a)
vmap( >(0.5), a)
```
As a pattern these all return boolean arrays, functions that return floats seem to be unaffected.

vmapreduce is unaffected:
```
a = rand( Int8,200,20)
@test vmapreduce(iszero,+,a) == mapreduce(iszero,+,a) #passes
@test sum(map(iszero,a)) == sum(vmap(iszero,a)) #fails
```
The inplace version seems affected as well:
```
a = rand( Int8,200,20)
out = rand( Bool,200,20)
vmap!(iszero,out,a)
@test out == map(iszero,a) #fails
```
Interestingly this seems to consistently return the same (wrong) result instead of the always changing values of the out of place version. Here again this seems to only affect functions that return bools.

This is just from some playing around not something I actually need but unless I'm violating some assumptions LoopVectorization makes this seems like a bug.

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.