Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use propagate_inbounds instead of inline #101

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: julia
os:
- linux
julia:
- 0.4
- 0.5
- 0.6
- nightly
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
julia 0.4
julia 0.5
BenchmarkTools 0.0.7
Compat 0.19.0
JLD
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.5/julia-0.5-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.5/julia-0.5-latest-win64.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
Expand Down
36 changes: 17 additions & 19 deletions src/array/indexing.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

function perf_hdindexing{T}(u_i::AbstractArray{T, 6}, u_ip1::AbstractArray{T, 6})
d1min = 3
d1max = size(u_i, 5) - 2
Expand Down Expand Up @@ -35,80 +34,79 @@ function kernel5{T}(idx, u_i::AbstractArray{T,6}, u_ip1::AbstractArray{T,6})
d3 = idx[3]
d4 = idx[4]
d5 = idx[5]

delta_12 = 0.5
delta_22 = 0.5
delta_32 = 0.5
delta_42 = 0.5
delta_52 = 0.5

u11_1 = (1/12)*u_i[ d1 - 2, d2, d3, d4, d5, 1] +
(-2/3)*u_i[ d1 - 1, d2, d3, d4, d5, 1] +
(0)*u_i[ d1 , d2, d3, d4, d5, 1] +
(2/3)*u_i[ d1 + 1, d2, d3, d4, d5, 1] +
(-1/12)*u_i[ d1 + 2, d2, d3, d4, d5, 1]

u22_1 = (1/12)*u_i[ d1, d2 - 2, d3, d4, d5, 1] +
(-2/3)*u_i[ d1, d2 - 1, d3, d4, d5, 1] +
(0)*u_i[ d1, d2 , d3, d4, d5, 1] +
(2/3)*u_i[ d1, d2 + 1, d3, d4, d5, 1] +
(-1/12)*u_i[ d1, d2 + 2, d3, d4, d5, 1]

u33_1 = (1/12)*u_i[ d1, d2, d3 - 2, d4, d5, 1] +
(-2/3)*u_i[ d1, d2, d3 - 1, d4, d5, 1] +
(0)*u_i[ d1, d2, d3 , d4, d5, 1] +
(2/3)*u_i[ d1, d2, d3 + 1, d4, d5, 1] +
(-1/12)*u_i[ d1, d2, d3 + 2, d4, d5, 1]

u44_1 = (1/12)*u_i[ d1, d2, d3, d4 - 2, d5, 1] +
(-2/3)*u_i[ d1, d2, d3, d4 - 1, d5, 1] +
(0)*u_i[ d1, d2, d3, d4 , d5, 1] +
(2/3)*u_i[ d1, d2, d3, d4 + 1, d5, 1] +
(-1/12)*u_i[ d1, d2, d3, d4 + 2, d5, 1]

u55_1 = (1/12)*u_i[ d1, d2, d3, d4, d5 - 2, 1] +
(-2/3)*u_i[ d1, d2, d3, d4, d5 - 1, 1] +
(0)*u_i[ d1, d2, d3, d4, d5 , 1] +
(2/3)*u_i[ d1, d2, d3, d4, d5 + 1, 1] +
(-1/12)*u_i[ d1, d2, d3, d4, d5 + 2, 1]
u_ip1[ d1, d2, d3, d4, d5, 2] = delta_12*u11_1 + delta_22*u22_1 + delta_32*u33_1 +

u_ip1[ d1, d2, d3, d4, d5, 2] = delta_12*u11_1 + delta_22*u22_1 + delta_32*u33_1 +
delta_42*u44_1 + delta_52*u55_1

u11_2 = (1/12)*u_i[ d1 - 2, d2, d3, d4, d5, 2] +
(-2/3)*u_i[ d1 - 1, d2, d3, d4, d5, 2] +
(0)*u_i[ d1 , d2, d3, d4, d5, 2] +
(2/3)*u_i[ d1 + 1, d2, d3, d4, d5, 2] +
(-1/12)*u_i[ d1 + 2, d2, d3, d4, d5, 2]

u22_2 = (1/12)*u_i[ d1, d2 - 2, d3, d4, d5, 2] +
(-2/3)*u_i[ d1, d2 - 1, d3, d4, d5, 2] +
(0)*u_i[ d1, d2 , d3, d4, d5, 2] +
(2/3)*u_i[ d1, d2 + 1, d3, d4, d5, 2] +
(-1/12)*u_i[ d1, d2 + 2, d3, d4, d5, 2]

u33_2 = (1/12)*u_i[ d1, d2, d3 - 2, d4, d5, 2] +
(-2/3)*u_i[ d1, d2, d3 - 1, d4, d5, 2] +
(0)*u_i[ d1, d2, d3 , d4, d5, 2] +
(2/3)*u_i[ d1, d2, d3 + 1, d4, d5, 2] +
(-1/12)*u_i[ d1, d2, d3 + 2, d4, d5, 2]

u44_2 = (1/12)*u_i[ d1, d2, d3, d4 - 2, d5, 2] +
(-2/3)*u_i[ d1, d2, d3, d4 - 1, d5, 2] +
(0)*u_i[ d1, d2, d3, d4 , d5, 2] +
(2/3)*u_i[ d1, d2, d3, d4 + 1, d5, 2] +
(-1/12)*u_i[ d1, d2, d3, d4 + 2, d5, 2]

u55_2 = (1/12)*u_i[ d1, d2, d3, d4, d5 - 2, 2] +
(-2/3)*u_i[ d1, d2, d3, d4, d5 - 1, 2] +
(0)*u_i[ d1, d2, d3, d4, d5 , 2] +
(2/3)*u_i[ d1, d2, d3, d4, d5 + 1, 2] +
(-1/12)*u_i[ d1, d2, d3, d4, d5 + 2, 2]
u_ip1[ d1, d2, d3, d4, d5, 1] = delta_12*u11_2 + delta_22*u22_2 + delta_32*u33_2 +

u_ip1[ d1, d2, d3, d4, d5, 1] = delta_12*u11_2 + delta_22*u22_2 + delta_32*u33_2 +
delta_42*u44_2 + delta_52*u55_2


return nothing
end

36 changes: 18 additions & 18 deletions src/array/sumindex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ end

ArrayStrides1(A::Array) = ArrayStrides1(A, size(A,1))

@inline Base.setindex!(A::ArrayLSLS, v, I::Int...) = A.data[I...] = v
Base.@propagate_inbounds Base.setindex!(A::ArrayLSLS, v, I::Int...) = A.data[I...] = v

@inline Base.unsafe_setindex!(A::ArrayLSLS, v, I::Int...) = Base.unsafe_setindex!(A.data, v, I...)
Base.@propagate_inbounds Base.unsafe_setindex!(A::ArrayLSLS, v, I::Int...) = Base.unsafe_setindex!(A.data, v, I...)

Base.first(A::ArrayLSLS) = first(A.data)

Expand All @@ -258,27 +258,27 @@ Base.size(A::MyArray) = size(A.data)
@inline Base.similar{T}(A::ArrayLSLS, ::Type{T}, dims::Tuple{Int,Int}) = ArrayLSLS(similar(A.data, T, (dims[1]+1,dims[2]+1)))
@inline Base.similar{T}(A::ArrayLSLS, ::Type{T}, dims::Tuple{Vararg{Int}}) = ArrayLSLS(similar(A.data, T, map(n->n+1, dims)))

@inline Base.getindex(A::ArrayLF, i::Int) = getindex(A.data, i)
@inline Base.getindex{T}(A::ArrayLS{T,2}, i::Int, j::Int) = getindex(A.data, i, j)
@inline Base.getindex{T}(A::ArrayLS{T,3}, i::Int, j::Int, k::Int) = getindex(A.data, i, j, k)
@inline Base.getindex{T}(A::ArrayLSLS{T,2}, i::Int, j::Int) = getindex(A.data, i, j)
@inline Base.unsafe_getindex(A::ArrayLF, indx::Int) = Base.unsafe_getindex(A.data, indx)
@inline Base.unsafe_getindex{T}(A::ArrayLS{T,2}, i::Int, j::Int) = Base.unsafe_getindex(A.data, i, j)
@inline Base.unsafe_getindex{T}(A::ArrayLS{T,3}, i::Int, j::Int, k::Int) = Base.unsafe_getindex(A.data, i, j, k)
@inline Base.unsafe_getindex{T}(A::ArrayLSLS{T,2}, i::Int, j::Int) = Base.unsafe_getindex(A.data, i, j)
Base.@propagate_inbounds Base.getindex(A::ArrayLF, i::Int) = getindex(A.data, i)
Base.@propagate_inbounds Base.getindex{T}(A::ArrayLS{T,2}, i::Int, j::Int) = getindex(A.data, i, j)
Base.@propagate_inbounds Base.getindex{T}(A::ArrayLS{T,3}, i::Int, j::Int, k::Int) = getindex(A.data, i, j, k)
Base.@propagate_inbounds Base.getindex{T}(A::ArrayLSLS{T,2}, i::Int, j::Int) = getindex(A.data, i, j)
Base.@propagate_inbounds Base.unsafe_getindex(A::ArrayLF, indx::Int) = Base.unsafe_getindex(A.data, indx)
Base.@propagate_inbounds Base.unsafe_getindex{T}(A::ArrayLS{T,2}, i::Int, j::Int) = Base.unsafe_getindex(A.data, i, j)
Base.@propagate_inbounds Base.unsafe_getindex{T}(A::ArrayLS{T,3}, i::Int, j::Int, k::Int) = Base.unsafe_getindex(A.data, i, j, k)
Base.@propagate_inbounds Base.unsafe_getindex{T}(A::ArrayLSLS{T,2}, i::Int, j::Int) = Base.unsafe_getindex(A.data, i, j)

@inline Base.getindex{T}(A::ArrayStrides{T,2}, i::Real, j::Real) = getindex(A.data, 1+A.strides[1]*(i-1)+A.strides[2]*(j-1))
@inline Base.getindex(A::ArrayStrides1, i::Real, j::Real) = getindex(A.data, i + A.stride1*(j-1))
@inline Base.unsafe_getindex{T}(A::ArrayStrides{T,2}, i::Real, j::Real) = Base.unsafe_getindex(A.data, 1+A.strides[1]*(i-1)+A.strides[2]*(j-1))
@inline Base.unsafe_getindex(A::ArrayStrides1, i::Real, j::Real) = Base.unsafe_getindex(A.data, i + A.stride1*(j-1))
Base.@propagate_inbounds Base.getindex{T}(A::ArrayStrides{T,2}, i::Real, j::Real) = getindex(A.data, 1+A.strides[1]*(i-1)+A.strides[2]*(j-1))
Base.@propagate_inbounds Base.getindex(A::ArrayStrides1, i::Real, j::Real) = getindex(A.data, i + A.stride1*(j-1))
Base.@propagate_inbounds Base.unsafe_getindex{T}(A::ArrayStrides{T,2}, i::Real, j::Real) = Base.unsafe_getindex(A.data, 1+A.strides[1]*(i-1)+A.strides[2]*(j-1))
Base.@propagate_inbounds Base.unsafe_getindex(A::ArrayStrides1, i::Real, j::Real) = Base.unsafe_getindex(A.data, i + A.stride1*(j-1))

@compat Base.IndexStyle(::Type{<:ArrayLF}) = IndexLinear()

if !applicable(Base.unsafe_getindex, [1 2], 1:1, 2)
@inline Base.unsafe_getindex(A::Array, I...) = @inbounds return A[I...]
@inline Base.unsafe_getindex(A::MyArray, I...) = @inbounds return A[I...]
@inline Base.unsafe_getindex(A::SubArray, I...) = @inbounds return A[I...]
@inline Base.unsafe_getindex(A::BitArray, I1::BitArray, I2::Int) = Base.unsafe_getindex(A, Base.to_index(I1), I2)
Base.@propagate_inbounds Base.unsafe_getindex(A::Array, I...) = @inbounds return A[I...]
Base.@propagate_inbounds Base.unsafe_getindex(A::MyArray, I...) = @inbounds return A[I...]
Base.@propagate_inbounds Base.unsafe_getindex(A::SubArray, I...) = @inbounds return A[I...]
Base.@propagate_inbounds Base.unsafe_getindex(A::BitArray, I1::BitArray, I2::Int) = Base.unsafe_getindex(A, Base.to_index(I1), I2)
end
# Add support for views with CartesianIndex in a comparable method to how indexing works
if v"0.5-" < VERSION < v"0.6-"
Expand Down