@@ -1028,47 +1028,47 @@ end
1028
1028
@test out1 == out2
1029
1029
end
1030
1030
1031
- function smoothdim! (s, x, α, Rpre, irng:: AbstractUnitRange , Rpost)
1032
- ifirst, ilast = first (irng), last (irng)
1033
- ifirst > ilast && return s
1034
- # @inbounds @fastmath for Ipost in Rpost
1035
- for Ipost in Rpost
1036
- # Initialize the first value along the filtered dimension
1037
- for Ipre in Rpre
1038
- s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1039
- end
1040
- # Handle all other entries
1041
- for i = ifirst+ 1 : ilast
1031
+ function smoothdim! (s, x, α, Rpre, irng:: AbstractUnitRange , Rpost)
1032
+ ifirst, ilast = first (irng), last (irng)
1033
+ ifirst > ilast && return s
1034
+ # @inbounds @fastmath for Ipost in Rpost
1035
+ for Ipost in Rpost
1036
+ # Initialize the first value along the filtered dimension
1042
1037
for Ipre in Rpre
1043
- s[Ipre, i, Ipost] = α* x[Ipre, i, Ipost] + (1 - α)* x[Ipre, i- 1 , Ipost]
1038
+ s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1039
+ end
1040
+ # Handle all other entries
1041
+ for i = ifirst+ 1 : ilast
1042
+ for Ipre in Rpre
1043
+ s[Ipre, i, Ipost] = α* x[Ipre, i, Ipost] + (1 - α)* x[Ipre, i- 1 , Ipost]
1044
+ end
1044
1045
end
1045
1046
end
1047
+ s
1046
1048
end
1047
- s
1048
- end
1049
- function smoothdim_avx! (s, x, α, Rpre, irng:: AbstractUnitRange , Rpost)
1050
- ifirst, ilast = first (irng), last (irng)
1051
- ifirst > ilast && return s
1052
- @avx for Ipost in Rpost
1053
- for Ipre in Rpre
1054
- s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1055
- for i = ifirst+ 1 : ilast
1056
- s[Ipre, i, Ipost] = α* x[Ipre, i, Ipost] + (1 - α)* x[Ipre, i- 1 , Ipost]
1049
+ function smoothdim_avx! (s, x, α, Rpre, irng:: AbstractUnitRange , Rpost)
1050
+ ifirst, ilast = first (irng), last (irng)
1051
+ ifirst > ilast && return s
1052
+ @avx for Ipost in Rpost
1053
+ for Ipre in Rpre
1054
+ s[Ipre, ifirst, Ipost] = x[Ipre, ifirst, Ipost]
1055
+ for i = ifirst+ 1 : ilast
1056
+ s[Ipre, i, Ipost] = α* x[Ipre, i, Ipost] + (1 - α)* x[Ipre, i- 1 , Ipost]
1057
+ end
1057
1058
end
1058
1059
end
1060
+ s
1059
1061
end
1060
- s
1061
- end
1062
- function smoothdim_ifelse_avx! (s, x, α, Rpre, irng :: AbstractUnitRange , Rpost)
1063
- ifirst, ilast = first (irng), last (irng)
1064
- ifirst > ilast && return s
1065
- @avx for Ipost in Rpost, i = ifirst: ilast, Ipre in Rpre
1066
- xi = x [Ipre, i, Ipost]
1067
- xim = i > ifirst ? x[Ipre, i - 1 , Ipost] : xi
1068
- s[Ipre, i, Ipost] = α * xi + ( 1 - α) * xim
1062
+ function smoothdim_ifelse_avx! (s, x, α, Rpre, irng :: AbstractUnitRange , Rpost)
1063
+ ifirst, ilast = first (irng), last (irng)
1064
+ ifirst > ilast && return s
1065
+ @avx for Ipost in Rpost, i = ifirst : ilast, Ipre in Rpre
1066
+ xi = x[Ipre, i, Ipost]
1067
+ xim = i > ifirst ? x[ Ipre, i - 1 , Ipost] : xi
1068
+ s [Ipre, i, Ipost] = α * xi + ( 1 - α) * xim
1069
+ end
1070
+ s
1069
1071
end
1070
- s
1071
- end
1072
1072
1073
1073
for T ∈ (Float32, Float64)
1074
1074
@testset " Mixed CartesianIndex/Int indexing" begin
@@ -1103,33 +1103,33 @@ end
1103
1103
end
1104
1104
1105
1105
1106
- function mul1! (y:: Vector{T} , A:: Matrix{UInt8} , x:: Vector{T} ) where T
1107
- packedstride = size (A, 1 )
1108
- m, n = size (A)
1109
- @avx for j ∈ eachindex (x)
1110
- for i ∈ eachindex (y)
1111
- k = 2 * ((i- 1 ) & 3 )
1112
- block = A[(j- 1 ) * packedstride + ((i- 1 ) >> 2 ) + 1 ]
1113
- Aij = (block >> k) & 3
1114
- y[i] += (((Aij >= 2 ) + (Aij >= 3 ))) * x[j]
1106
+ function mul1! (y:: Vector{T} , A:: Matrix{UInt8} , x:: Vector{T} ) where T
1107
+ packedstride = size (A, 1 )
1108
+ m, n = size (A)
1109
+ @avx for j ∈ eachindex (x)
1110
+ for i ∈ eachindex (y)
1111
+ k = 2 * ((i- 1 ) & 3 )
1112
+ block = A[(j- 1 ) * packedstride + ((i- 1 ) >> 2 ) + 1 ]
1113
+ Aij = (block >> k) & 3
1114
+ y[i] += (((Aij >= 2 ) + (Aij >= 3 ))) * x[j]
1115
+ end
1116
+ end
1117
+ y
1118
+ end
1119
+ function mul2! (y:: Vector{T} , A:: Matrix{UInt8} , x:: Vector{T} ) where T
1120
+ packedstride = size (A, 1 )
1121
+ m, n = size (A)
1122
+ for j ∈ eachindex (x)
1123
+ for i ∈ eachindex (y)
1124
+ k = 2 * ((i- 1 ) & 3 )
1125
+ block = A[(j- 1 ) * packedstride + ((i- 1 ) >> 2 ) + 1 ]
1126
+ Aij = (block >> k) & 3
1127
+ y[i] += (((Aij >= 2 ) + (Aij >= 3 ))) * x[j]
1128
+ end
1115
1129
end
1130
+ y
1116
1131
end
1117
- y
1118
- end
1119
- function mul2! (y:: Vector{T} , A:: Matrix{UInt8} , x:: Vector{T} ) where T
1120
- packedstride = size (A, 1 )
1121
- m, n = size (A)
1122
- for j ∈ eachindex (x)
1123
- for i ∈ eachindex (y)
1124
- k = 2 * ((i- 1 ) & 3 )
1125
- block = A[(j- 1 ) * packedstride + ((i- 1 ) >> 2 ) + 1 ]
1126
- Aij = (block >> k) & 3
1127
- y[i] += (((Aij >= 2 ) + (Aij >= 3 ))) * x[j]
1128
- end
1129
- end
1130
- y
1131
- end
1132
- if Base. libllvm_version ≥ v " 8" || LoopVectorization. VectorizationBase. SIMD_NATIVE_INTEGERS
1132
+
1133
1133
@testset " UInt8 mul" begin
1134
1134
for n in 1 : 200
1135
1135
v1 = rand (n); v3 = copy (v1);
@@ -1138,17 +1138,16 @@ if Base.libllvm_version ≥ v"8" || LoopVectorization.VectorizationBase.SIMD_NAT
1138
1138
@test mul1! (v1, A, v2) ≈ mul2! (v3, A, v2)
1139
1139
end
1140
1140
end
1141
- end
1142
1141
1143
- @test_throws LoadError @macroexpand begin # pull #172
1144
- @avx for i in eachindex (xs)
1145
- if i in axes (ys,1 )
1146
- xs[i] = ys[i]
1147
- else
1148
- xs[i] = zero (eltype (ys))
1142
+ @test_throws LoadError @macroexpand begin # pull #172
1143
+ @avx for i in eachindex (xs)
1144
+ if i in axes (ys,1 )
1145
+ xs[i] = ys[i]
1146
+ else
1147
+ xs[i] = zero (eltype (ys))
1148
+ end
1149
1149
end
1150
1150
end
1151
- end
1152
1151
1153
1152
end
1154
1153
0 commit comments