Skip to content

Commit

Permalink
Fix type instability with static sized arrays (#54)
Browse files Browse the repository at this point in the history
* Fix type instability with static sized arrays

* Bump patch version
  • Loading branch information
chriselrod authored Jan 20, 2021
1 parent e8b6534 commit 6af1d36
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Octavian"
uuid = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4"
authors = ["Mason Protter", "Chris Elrod", "Dilum Aluthge", "contributors"]
version = "0.2.2"
version = "0.2.3"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
2 changes: 1 addition & 1 deletion src/block_sizes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ Splits both `M` and `N` into blocks when trying to spawn a large number of threa

Miter = clamp(div_fast(M, W*StaticInt{mᵣ}() * MᵣW_mul_factor), 1, _nspawn)
nspawn = div_fast(_nspawn, Miter)
Niter = if (nspawn 1) & (Miter < _nspawn)
if (nspawn 1) & (Miter < _nspawn)
# rebalance Miter
Miter = cld_fast(_nspawn, cld_fast(_nspawn, Miter))
nspawn = div_fast(_nspawn, Miter)
Expand Down
5 changes: 3 additions & 2 deletions src/integerdivision.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@inline cld_fast(x, y) = cld(x, y)
@inline function cld_fast(x::I, y) where {I <: Integer}
@inline function cld_fast(x::I, y) where {I <: Base.BitInteger}
d = div_fast(x, y)
(d + (d * unsigned(y) != unsigned(x))) % I
end
cld_fast(::StaticInt{N}, ::StaticInt{M}) where {N,M}= (StaticInt{N}() + StaticInt{M}() + One()) ÷ StaticInt{M}()
@inline cld_fast(::StaticInt{N}, y) where {N} = cld_fast(N, y)
cld_fast(::StaticInt{N}, ::StaticInt{M}) where {N,M}= (StaticInt{N}() + StaticInt{M}() - One()) ÷ StaticInt{M}()
@inline function divrem_fast(x::I, y) where {I <: Integer}
ux = unsigned(x); uy = unsigned(y)
d = Base.udiv_int(ux, uy)
Expand Down
5 changes: 5 additions & 0 deletions test/integer_division.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

@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
@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


3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Random
import Test
import VectorizationBase

using Test: @testset, @test, @test_throws
using Test: @testset, @test, @test_throws, @inferred

include("test_suite_preamble.jl")

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

include("block_sizes.jl")
include("init.jl")
include("integer_division.jl")
include("macrokernels.jl")
include("matmul_coverage.jl")
include("utils.jl")
Expand Down

4 comments on commit 6af1d36

@DilumAluthge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/28381

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" 6af1d365fffe820ac0781c8ce295769880145b3a
git push origin v0.2.3

Also, note the warning: Version 0.2.3 skips over 0.2.2
This can be safely ignored. However, if you want to fix this you can do so. Call register() again after making the fix. This will update the Pull request.

@DilumAluthge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/28381

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.3 -m "<description of version>" 6af1d365fffe820ac0781c8ce295769880145b3a
git push origin v0.2.3

Please sign in to comment.