Skip to content

Commit 891ab4d

Browse files
committed
Fix support for indexing ranges and add tests.
1 parent dba62cb commit 891ab4d

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

Manifest.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
4949

5050
[[SIMDPirates]]
5151
deps = ["VectorizationBase"]
52-
git-tree-sha1 = "a27b812034efdb062ec3d9e787bc299510057b3d"
52+
git-tree-sha1 = "8f1ed076d4e90047cf263b3416daa761081ca32c"
5353
uuid = "21efa798-c60a-11e8-04d3-e1a92915a26a"
54-
version = "0.3.5"
54+
version = "0.3.6"
5555

5656
[[SLEEFPirates]]
5757
deps = ["Libdl", "SIMDPirates", "VectorizationBase"]

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ VectorizationBase = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
1212

1313
[compat]
1414
Parameters = "0"
15-
SIMDPirates = "0.3.5, 0.4, 0.5"
15+
SIMDPirates = "0.3.6, 0.4, 0.5"
1616
SLEEFPirates = "0.3.2, 0.4, 0.5"
1717
VectorizationBase = "0.2.5, 0.3, 0.4"
1818
julia = "1.1"

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
[![Codecov](https://codecov.io/gh/chriselrod/LoopVectorization.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/chriselrod/LoopVectorization.jl)
88

99
## Installation
10-
```
10+
11+
```julia
1112
using Pkg
1213
Pkg.add("LoopVectorization")
1314
```

src/reconstruct_loopset.jl

+6
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ function add_mref!(ls::LoopSet, ars::ArrayRefStruct, arraysymbolinds::Vector{Sym
104104
pushpreamble!(ls, Expr(:(=), vptr(ar), LoopValue()))
105105
ar
106106
end
107+
function add_mref!(ls::LoopSet, ars::ArrayRefStruct, arraysymbolinds::Vector{Symbol}, opsymbols::Vector{Symbol}, i::Int, ::Type{<:AbstractRange{T}}) where {T}
108+
ar = ArrayReferenceMeta(ls, ars, arraysymbolinds, opsymbols, Symbol(""), gensym())
109+
pushpreamble!(ls, Expr(:(=), vptr(ar), Expr(:macrocall, Symbol("@inbounds"), LineNumberNode(@__LINE__, @__FILE__), Expr(:ref, :vargs, i))))
110+
ar
111+
end
107112

108113

109114

@@ -200,6 +205,7 @@ end
200205
# elbytes(::VectorizationBase.AbstractPointer{T}) where {T} = sizeof(T)::Int
201206
typeeltype(::Type{P}) where {T,P<:VectorizationBase.AbstractPointer{T}} = T
202207
typeeltype(::Type{LoopValue}) = Int8
208+
typeeltype(::Type{<:AbstractRange{T}}) where {T} = T
203209

204210
function add_array_symbols!(ls::LoopSet, arraysymbolinds::Vector{Symbol}, offset::Int)
205211
for (i,as) enumerate(arraysymbolinds)

test/runtests.jl

+28
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,21 @@ end
959959
x[i] = a
960960
end
961961
end
962+
963+
function mysumavx(x)
964+
s = zero(eltype(x))
965+
@avx for i eachindex(x)
966+
s += x[i]
967+
end
968+
s
969+
end
970+
function mysum_avx(x)
971+
s = zero(eltype(x))
972+
@_avx for i eachindex(x)
973+
s += x[i]
974+
end
975+
s
976+
end
962977

963978
for T (Float32, Float64)
964979
@show T, @__LINE__
@@ -1101,6 +1116,19 @@ end
11011116
@avx x .= 34.242;
11021117
fill!(q2, 34.242)
11031118
@test x == q2
1119+
1120+
s = sum(x)
1121+
@test s mysumavx(x)
1122+
@test s mysum_avx(x)
1123+
r = T == Float32 ? (Int32(-10):Int32(234)) : -10:234
1124+
s = sum(r)
1125+
@test s mysumavx(r)
1126+
@test s mysum_avx(r)
1127+
r = T(-10):T(2.3):T(1000)
1128+
s = T == Float32 ? sum(collect(r)) : sum(r)
1129+
@test s mysumavx(r)
1130+
@test s mysum_avx(r)
1131+
11041132
end
11051133
end
11061134

0 commit comments

Comments
 (0)