Skip to content

Commit 6af1d36

Browse files
authored
Fix type instability with static sized arrays (#54)
* Fix type instability with static sized arrays * Bump patch version
1 parent e8b6534 commit 6af1d36

5 files changed

+12
-5
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Octavian"
22
uuid = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4"
33
authors = ["Mason Protter", "Chris Elrod", "Dilum Aluthge", "contributors"]
4-
version = "0.2.2"
4+
version = "0.2.3"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/block_sizes.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ Splits both `M` and `N` into blocks when trying to spawn a large number of threa
223223

224224
Miter = clamp(div_fast(M, W*StaticInt{mᵣ}() * MᵣW_mul_factor), 1, _nspawn)
225225
nspawn = div_fast(_nspawn, Miter)
226-
Niter = if (nspawn 1) & (Miter < _nspawn)
226+
if (nspawn 1) & (Miter < _nspawn)
227227
# rebalance Miter
228228
Miter = cld_fast(_nspawn, cld_fast(_nspawn, Miter))
229229
nspawn = div_fast(_nspawn, Miter)

src/integerdivision.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
@inline cld_fast(x, y) = cld(x, y)
2-
@inline function cld_fast(x::I, y) where {I <: Integer}
2+
@inline function cld_fast(x::I, y) where {I <: Base.BitInteger}
33
d = div_fast(x, y)
44
(d + (d * unsigned(y) != unsigned(x))) % I
55
end
6-
cld_fast(::StaticInt{N}, ::StaticInt{M}) where {N,M}= (StaticInt{N}() + StaticInt{M}() + One()) ÷ StaticInt{M}()
6+
@inline cld_fast(::StaticInt{N}, y) where {N} = cld_fast(N, y)
7+
cld_fast(::StaticInt{N}, ::StaticInt{M}) where {N,M}= (StaticInt{N}() + StaticInt{M}() - One()) ÷ StaticInt{M}()
78
@inline function divrem_fast(x::I, y) where {I <: Integer}
89
ux = unsigned(x); uy = unsigned(y)
910
d = Base.udiv_int(ux, uy)

test/integer_division.jl

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
@test @inferred(Octavian.cld_fast(Octavian.StaticInt(6), Octavian.StaticInt(2))) == @inferred(Octavian.cld_fast(11, Octavian.StaticInt(4))) == @inferred(Octavian.cld_fast(Octavian.StaticInt(7), 3)) == @inferred(Octavian.cld_fast(9, 4)) == 3
3+
@test @inferred(Octavian.cld_fast(Octavian.StaticInt(7), Octavian.StaticInt(2))) == @inferred(Octavian.cld_fast(13, Octavian.StaticInt(4))) == @inferred(Octavian.cld_fast(Octavian.StaticInt(8), 2)) == @inferred(Octavian.cld_fast(15, 4)) == 4
4+
5+

test/runtests.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Random
99
import Test
1010
import VectorizationBase
1111

12-
using Test: @testset, @test, @test_throws
12+
using Test: @testset, @test, @test_throws, @inferred
1313

1414
include("test_suite_preamble.jl")
1515

@@ -20,6 +20,7 @@ Random.seed!(123)
2020

2121
include("block_sizes.jl")
2222
include("init.jl")
23+
include("integer_division.jl")
2324
include("macrokernels.jl")
2425
include("matmul_coverage.jl")
2526
include("utils.jl")

0 commit comments

Comments
 (0)