Skip to content

Commit a7f9e1b

Browse files
Tokazamachriselrod
andauthored
Update Project.toml (#416)
* Update Project.toml * a few updates toward Static 0.7 * further Static 0.7 updates; drop older ones to reduce chances of regressions Co-authored-by: Chris Elrod <elrodc@gmail.com>
1 parent 03de201 commit a7f9e1b

File tree

9 files changed

+35
-2352
lines changed

9 files changed

+35
-2352
lines changed

Project.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ ArrayInterfaceOffsetArrays = "0.1.2"
3535
ArrayInterfaceStaticArrays = "0.1.2"
3636
CPUSummary = "0.1.3 - 0.1.8, 0.1.11"
3737
ChainRulesCore = "1"
38-
CloseOpenIntervals = "0.1.2"
38+
CloseOpenIntervals = "0.1.10"
3939
DocStringExtensions = "0.8, 0.9"
4040
ForwardDiff = "0.9, 0.10"
4141
HostCPUFeatures = "0.1.3"
@@ -47,7 +47,7 @@ SIMDDualNumbers = "0.1"
4747
SIMDTypes = "0.1"
4848
SLEEFPirates = "0.6.23"
4949
SpecialFunctions = "1, 2"
50-
Static = "0.3.3, 0.4, 0.6"
50+
Static = "0.7"
5151
ThreadingUtilities = "0.5"
5252
UnPack = "1"
5353
VectorizationBase = "0.21.21"

src/broadcast.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function LowDimArray{D0}(data::LowDimArray{D1,T,N,A}) where {D0,T,N,D1,A<:Abstra
2323
end
2424
Base.@propagate_inbounds Base.getindex(
2525
A::LowDimArray,
26-
i::Vararg{Union{Integer,CartesianIndex},K},
26+
i::Vararg{Union{StaticInt,Integer,CartesianIndex},K},
2727
) where {K} = getindex(A.data, i...)
2828
@inline Base.size(A::LowDimArray) = Base.size(A.data)
2929
@inline Base.size(A::LowDimArray, i) = Base.size(A.data, i)
@@ -238,8 +238,8 @@ function _strides_expr(@nospecialize(s), @nospecialize(x), R::Vector{Int}, D::Ve
238238
q
239239
end
240240
@generated function _strides(
241-
s::Tuple{Vararg{Integer,N}},
242-
x::Tuple{Vararg{Integer,N}},
241+
s::Tuple{Vararg{Union{StaticInt,Integer},N}},
242+
x::Tuple{Vararg{Union{StaticInt,Integer},N}},
243243
::Val{R},
244244
::Val{D},
245245
) where {N,R,D}

src/codegen/lower_memory_common.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
function _addoffset!(
5858
ret::Expr,
5959
vloopstride,
60-
indexstride::Union{Integer,MaybeKnown},
60+
indexstride::Union{Int,MaybeKnown},
6161
index,
6262
offset,
6363
calcbypointeroffset::Bool,
@@ -90,8 +90,8 @@ function __addoffset!(
9090
end
9191
function __addoffset!(
9292
ret::Expr,
93-
vloopstride::Union{Integer,MaybeKnown},
94-
indexstride::Union{Integer,MaybeKnown},
93+
vloopstride::Union{Int,MaybeKnown},
94+
indexstride::Union{Int,MaybeKnown},
9595
index,
9696
offset,
9797
calcbypointeroffset::Bool,

src/condense_loopset.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,14 @@ end
357357
val(x) = Expr(:call, Expr(:curly, :Val, x))
358358

359359
@inline gespf1(x, i) = gesp(x, i)
360-
@inline gespf1(x::StridedPointer{T,1}, i::Tuple{I}) where {T,I<:Integer} = gesp(x, i)
361-
@inline gespf1(x::StridedBitPointer{T,1}, i::Tuple{I}) where {T,I<:Integer} = gesp(x, i)
360+
@inline gespf1(x::StridedPointer{T,1}, i::Tuple{I}) where {T,I<:Union{Integer,StaticInt}} = gesp(x, i)
361+
@inline gespf1(x::StridedBitPointer{T,1}, i::Tuple{I}) where {T,I<:Union{Integer,StaticInt}} = gesp(x, i)
362362
@inline gespf1(x::StridedPointer{T,1}, i::Tuple{Zero}) where {T} = x
363363
@inline gespf1(x::StridedBitPointer{T,1}, i::Tuple{Zero}) where {T} = x
364364
@generated function gespf1(
365365
x::AbstractStridedPointer{T,N,C,B,R},
366366
i::Tuple{I},
367-
) where {T,N,I<:Integer,C,B,R}
367+
) where {T,N,I<:Union{Integer,StaticInt},C,B,R}
368368
ri = argmin(R)
369369
quote
370370
$(Expr(:meta, :inline))

src/modeling/graphs.jl

+17-26
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function pushexpr!(ex::Expr, mk::MaybeKnown)
6868
end
6969
pushexpr!(ex::Expr, x::Union{Symbol,Expr}) = (push!(ex.args, x); nothing)
7070
pushexpr!(ex::Expr, x::Integer) = (push!(ex.args, staticexpr(convert(Int, x))); nothing)
71+
pushexpr!(ex::Expr, @nospecialize(x::StaticInt)) = (push!(ex.args, x); nothing)
7172
MaybeKnown(x::Integer) = MaybeKnown(convert(Int, x), Symbol("##UNDEFINED##"), true)
7273
MaybeKnown(x::Integer, default::Int) = MaybeKnown(x)
7374
MaybeKnown(x::Symbol, default::Int) = MaybeKnown(default, x, false)
@@ -926,19 +927,20 @@ function add_block!(ls::LoopSet, ex::Expr, elementbytes::Int, position::Int)
926927
push!(ls, x, elementbytes, position)
927928
end
928929
end
929-
function maybestatic!(expr::Expr)
930-
if expr.head === :call
931-
f = first(expr.args)
932-
if f === :length
933-
expr.args[1] = GlobalRef(ArrayInterface, :static_length)
934-
elseif f === :size && length(expr.args) == 3
935-
i = expr.args[3]
936-
if i isa Integer
937-
expr.args[1] = GlobalRef(ArrayInterface, :size)
938-
expr.args[3] = staticexpr(convert(Int, i)::Int)
930+
function makestatic!(expr)
931+
expr isa Expr || return expr
932+
for i = eachindex(expr.args)
933+
ex = expr.args[i]
934+
if ex isa Int
935+
expr.args[i] = staticexpr(ex)
936+
elseif ex isa Symbol
937+
if ex === :length
938+
expr.args[i] = GlobalRef(ArrayInterface, :static_length)
939+
elseif Base.sym_in(ex, (:axes, :size))
940+
expr.args[i] = GlobalRef(ArrayInterface, ex)
939941
end
940-
else
941-
static_literals!(expr)
942+
elseif ex isa Expr
943+
makestatic!(ex)
942944
end
943945
end
944946
expr
@@ -957,7 +959,7 @@ function add_loop_bound!(
957959
upper::Bool,
958960
step::Bool,
959961
)::MaybeKnown
960-
maybestatic!(bound)
962+
makestatic!(bound)
961963
N = gensym!(
962964
ls,
963965
string(itersym) *
@@ -966,17 +968,6 @@ function add_loop_bound!(
966968
pushprepreamble!(ls, Expr(:(=), N, bound))
967969
MaybeKnown(N, upper ? 1024 : 1)
968970
end
969-
static_literals!(s::Symbol) = s
970-
function static_literals!(q::Expr)
971-
for (i, ex) enumerate(q.args)
972-
if ex isa Number
973-
q.args[i] = staticexpr(ex)
974-
elseif ex isa Expr
975-
static_literals!(ex)
976-
end
977-
end
978-
q
979-
end
980971
function range_loop!(
981972
ls::LoopSet,
982973
itersym::Symbol,
@@ -1021,7 +1012,7 @@ function oneto_loop!(ls::LoopSet, r::Expr, itersym::Symbol)::Loop
10211012
rangename = lensym = Symbol("")
10221013
MaybeKnown(convert(Int, otN)::Int, 0)
10231014
else
1024-
otN isa Expr && maybestatic!(otN)
1015+
otN isa Expr && makestatic!(otN)
10251016
lensym = N = gensym!(ls, "loop" * string(itersym))
10261017
rangename = gensym!(ls, "range")
10271018
pushprepreamble!(ls, Expr(:(=), N, otN))
@@ -1084,7 +1075,7 @@ function misc_loop!(
10841075
Expr(
10851076
:(=),
10861077
rangename,
1087-
Expr(:call, lv(:canonicalize_range), :(@inbounds $(static_literals!(r)))),
1078+
Expr(:call, lv(:canonicalize_range), :(@inbounds $(makestatic!(r)))),
10881079
),
10891080
)
10901081
pushprepreamble!(

0 commit comments

Comments
 (0)