Mercurial > repos > public > sbplib_julia
comparison diffOp.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 | 38733e84ef1a |
comparison
equal
deleted
inserted
replaced
80:700a74c41b26 | 81:7f72e7e14659 |
---|---|
46 u .= L.a * u | 46 u .= L.a * u |
47 return nothing | 47 return nothing |
48 end | 48 end |
49 | 49 |
50 # u = L*v | 50 # u = L*v |
51 function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector) | 51 @inline function apply!(L::Laplace{2}, u::AbstractVector, v::AbstractVector) |
52 u .= 0*u | 52 u .= 0*u |
53 h = Grid.spacings(L.grid) | 53 h = Grid.spacings(L.grid) |
54 | 54 |
55 li = LinearIndices(L.grid.numberOfPointsPerDim) | 55 li = LinearIndices(L.grid.numberOfPointsPerDim) |
56 n_x, n_y = L.grid.numberOfPointsPerDim | 56 n_x, n_y = L.grid.numberOfPointsPerDim |
58 | 58 |
59 # For each x | 59 # For each x |
60 temp = zeros(eltype(u), n_y) | 60 temp = zeros(eltype(u), n_y) |
61 for i ∈ 1:n_x | 61 for i ∈ 1:n_x |
62 | 62 |
63 v_i = view(v, li[i,:]) | 63 @inbounds v_i = view(v, li[i,:]) |
64 apply!(L.op, temp, v_i, h[2]) | 64 @inbounds apply!(L.op, temp, v_i, h[2]) |
65 | 65 |
66 u[li[i,:]] += temp | 66 @inbounds u[li[i,:]] += temp |
67 end | 67 end |
68 | 68 |
69 # For each y | 69 # For each y |
70 temp = zeros(eltype(u), n_x) | 70 temp = zeros(eltype(u), n_x) |
71 for i ∈ 1:n_y | 71 for i ∈ 1:n_y |
72 v_i = view(v, li[:,i]) | 72 @inbounds v_i = view(v, li[:,i]) |
73 apply!(L.op, temp, v_i, h[1]) | 73 @inbounds apply!(L.op, temp, v_i, h[1]) |
74 | 74 |
75 u[li[:,i]] += temp | 75 @inbounds u[li[:,i]] += temp |
76 end | 76 end |
77 | 77 |
78 u .= L.a*u | 78 u .= L.a*u |
79 | 79 |
80 return nothing | 80 return nothing |