comparison sbpD2.jl @ 81:7f72e7e14659 patch_based_test

Add benchmarktest and mark all apply functions with @inline and @inbounds
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 24 Jan 2019 14:58:22 +0100
parents 700a74c41b26
children 170e5447bc19
comparison
equal deleted inserted replaced
80:700a74c41b26 81:7f72e7e14659
1 abstract type ConstantStencilOperator end 1 abstract type ConstantStencilOperator end
2 2
3 function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real) 3 @inline function apply!(op::ConstantStencilOperator, u::AbstractVector, v::AbstractVector, h::Real)
4 N = length(v) 4 N = length(v)
5 cSize = closureSize(op) 5 cSize = closureSize(op)
6 6
7 for i ∈ range(1; length=cSize) 7 for i ∈ range(1; length=cSize)
8 u[i] = apply(op.closureStencils[i], v, i)/h^2 8 @inbounds u[i] = apply(op.closureStencils[i], v, i)/h^2
9 end 9 end
10 10
11 innerStart = 1 + cSize 11 innerStart = 1 + cSize
12 innerEnd = N - cSize 12 innerEnd = N - cSize
13 for i ∈ range(innerStart, stop=innerEnd) 13 for i ∈ range(innerStart, stop=innerEnd)
14 u[i] = apply(op.innerStencil, v, i)/h^2 14 @inbounds u[i] = apply(op.innerStencil, v, i)/h^2
15 end 15 end
16 16
17 for i ∈ range(innerEnd+1, length=cSize) 17 for i ∈ range(innerEnd+1, length=cSize)
18 u[i] = Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2 18 @inbounds u[i] = Int(op.parity)*apply(flip(op.closureStencils[N-i+1]), v, i)/h^2
19 end 19 end
20 20
21 return nothing 21 return nothing
22 end 22 end
23 23