Skip to content

Commit 93fef1c

Browse files
committed
Improved external function support by allowing multiple modules, e.g. a.b.c(x,y,z).
1 parent e07f203 commit 93fef1c

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/src/examples/filtering.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Here, we convolve a small matrix `kern` with a larger matrix `A`, storing the results in `out`, using Julia's generic [Cartesian Indexing](https://julialang.org/blog/2016/02/iteration/):
44
```julia
5+
using LoopVectorization, OffsetArrays, Images
6+
kern = Images.Kernel.gaussian((1, 1), (3, 3))
57
function filter2davx!(out::AbstractMatrix, A::AbstractMatrix, kern)
68
@avx for J in CartesianIndices(out)
79
tmp = zero(eltype(out))

src/add_compute.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ function add_compute!(
187187
mpref::Union{Nothing,ArrayReferenceMetaPosition} = nothing
188188
)
189189
@assert ex.head === :call
190-
instr = instruction(first(ex.args))::Symbol
190+
# instr = instruction(first(ex.args))::Symbol
191+
instr = instruction!(ls, first(ex.args))::Symbol
191192
args = @view(ex.args[2:end])
192193
(instr === :(^) && length(args) == 2 && (args[2] isa Number)) && return add_pow!(ls, var, args[1], args[2], elementbytes, position)
193194
vparents = Operation[]

src/graphs.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ end
450450
function instruction(x)
451451
x isa Symbol ? x : last(x.args).value
452452
end
453+
function instruction!(ls::LoopSet, x)
454+
x isa Symbol && return x
455+
instr = last(x.args).value
456+
if Instruction(instr) keys(COST)
457+
instr = gensym(:f)
458+
pushpreamble!(ls, Expr(:(=), instr, x))
459+
end
460+
instr
461+
end
453462
function add_operation!(
454463
ls::LoopSet, LHS::Symbol, RHS::Expr, elementbytes::Int, position::Int
455464
)

0 commit comments

Comments
 (0)