Skip to content

Wrong result with Int16 and offset index in for loop #52

@zsoerenm

Description

@zsoerenm

Here is a MWE:

function test_for_with_different_index!(a, b, c, start_sample, num_samples)
    @inbounds for i = start_sample:num_samples + start_sample - 1
        c[i] = b[i] * a[i]
    end
end

function test_for_with_different_index_avx!(a, b, c, start_sample, num_samples)
    @avx for i = start_sample:num_samples + start_sample - 1
        c[i] = b[i] * a[i]
    end
end

a = rand(Int16, 1000)
b = rand(Int16, 1000)
c = similar(a_re)
c_avx = similar(a_re)
test_for_with_different_index!(a, b, c, 30, 800)
test_for_with_different_index_avx!(a, b, c_avx, 30, 800)
@test c[30:829] == c_avx[30:829]
Test Failed at /home/zorn/Documents/Code/Testing/test_avx.jl:44
  Expression: c[30:829] == c_avx[30:829]
   Evaluated: Int16[-17628, -17250, -31956, 29328, 2240, 8696, -8285, 1924, 16032, 9148    25940, -4788, 23094, 18864, -21520, 6014, -7572, -18266, -15094, 28000] == Int16[-17628, -17250, -31956, 29328, 2240, 8696, -8285, 1924, 16032, 9148    25940, -4788, 23094, 18864, -21520, 6014, -7572, 32544, 0, 16048]

Only the last three entries are wrong.

With floats the result is correct, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions