Skip to content

Commit 82a68e7

Browse files
authored
Precomp for >= 1.8.1beta (#132)
* Adjust blocking behavior to cap cache use at L2e and L3e * Precompile * Bump version
1 parent c7ebc65 commit 82a68e7

File tree

8 files changed

+44
-16
lines changed

8 files changed

+44
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.3.11"
4+
version = "0.3.12"
55

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

src/Octavian.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export matmul
2323
export matmul_serial!
2424
export matmul_serial
2525

26+
debug() = false
27+
2628
include("global_constants.jl")
2729
include("types.jl")
2830
include("integerdivision.jl")
@@ -36,4 +38,21 @@ include("complex_matmul.jl")
3638

3739
include("init.jl") # `Octavian.__init__()` is defined in this file
3840

41+
@static if VERSION >= v"1.8.0-beta1"
42+
let
43+
__init__()
44+
A64 = rand(100,100)
45+
matmul(A64,A64)
46+
matmul(A64',A64)
47+
matmul(A64,A64')
48+
matmul(A64',A64')
49+
A32 = rand(Float32,100,100)
50+
matmul(A32,A32)
51+
matmul(A32',A32)
52+
matmul(A32,A32')
53+
matmul(A32',A32')
54+
end
55+
end
56+
57+
3958
end # module Octavian

src/global_constants.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ MᵣW_mul_factor(::True) = StaticInt{4}()
1616
MᵣW_mul_factor(::False) = StaticInt{9}()
1717
MᵣW_mul_factor() = MᵣW_mul_factor(has_feature(Val(:x86_64_avx512f)))
1818

19-
W₁Default(::True) = StaticFloat64{0.0007423708195588264}()
20-
W₂Default(::True) = StaticFloat64{0.7398765624419478}()
21-
R₁Default(::True) = StaticFloat64{0.4697043382682602}()
22-
R₂Default(::True) = StaticFloat64{0.6342912896800855}()
19+
W₁Default(::True) = StaticFloat64{0.0009898277594117685}()
20+
W₂Default(::True) = StaticFloat64{0.9865020832559304}()
21+
R₁Default(::True) = StaticFloat64{0.5820044063603483}()
22+
R₂Default(::True) = StaticFloat64{0.7580885846640107}()
2323

2424
W₁Default_arch(::Val{:znver1}) = StaticFloat64{0.053918949422353986}()
2525
W₂Default_arch(::Val{:znver1}) = StaticFloat64{0.3013238122374886}()
@@ -73,7 +73,7 @@ bcache_count() = VectorizationBase.num_cache(second_cache())
7373
const BCACHEPTR = Ref{Ptr{Cvoid}}(C_NULL)
7474
const BCACHE_LOCK = Threads.Atomic{UInt}(zero(UInt))
7575

76-
@static if Sys.WORD_SIZE 32
76+
@static if Sys.WORD_SIZE == 32
7777
const ACACHEPTR = Ref{Ptr{Cvoid}}(C_NULL)
7878
end
7979

src/init.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,35 @@ function __init__()
1212
)
1313
@warn msg
1414
end
15-
reseet_bcache_lock!()
15+
reset_bcache_lock!()
1616
end
1717

1818
function init_bcache()
1919
if bcache_count() Zero()
20-
BCACHEPTR[] = VectorizationBase.valloc(second_cache_size() * bcache_count(), Cvoid, ccall(:jl_getpagesize, Int, ()))
20+
if BCACHEPTR[] == C_NULL
21+
BCACHEPTR[] = VectorizationBase.valloc(second_cache_size() * bcache_count(), Cvoid, ccall(:jl_getpagesize, Int, ()))
22+
end
2123
end
2224
nothing
2325
end
2426

25-
@static if Sys.WORD_SIZE 32
27+
@static if Sys.WORD_SIZE == 32
2628
function init_acache()
27-
ACACHEPTR[] = VectorizationBase.valloc(first_cache_size() * init_num_tasks(), Cvoid, ccall(:jl_getpagesize, Int, ()))
29+
if ACACHEPTR[] == C_NULL
30+
ACACHEPTR[] = VectorizationBase.valloc(first_cache_size() * init_num_tasks(), Cvoid, ccall(:jl_getpagesize, Int, ()))
31+
end
2832
nothing
2933
end
3034
else
3135
init_acache() = nothing
3236
end
3337

3438
function init_num_tasks()
35-
num_tasks = _read_environment_num_tasks()::Int
39+
num_tasks = _read_environment_num_tasks()
3640
OCTAVIAN_NUM_TASKS[] = num_tasks
3741
end
3842

39-
function _read_environment_num_tasks()
43+
function _read_environment_num_tasks()::Int
4044
environment_variable = get(ENV, "OCTAVIAN_NUM_TASKS", "")::String
4145
nt = min(Threads.nthreads(), VectorizationBase.num_cores())::Int
4246
if isempty(environment_variable)

src/macrokernels.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,11 @@ function packaloopmul!(
132132
α, β, M, K, N
133133
) where {T}
134134
Ãₚ, buffer = alloc_a_pack(K, Val(T))
135+
Mᵣ, Nᵣ = matmul_params(Val(T))
136+
if (debug() && (first_cache_size(Val(T)) < Mᵣ*pick_vector_width(T)*K*cld(M,Mᵣ*pick_vector_width(T))))
137+
throw("First cache size too small: M: $M, K: $K, N: $N, first cache size: $(first_cache_size(Val(T)))")
138+
end
135139
GC.@preserve buffer begin
136-
Mᵣ, Nᵣ = matmul_params(Val(T))
137140
packamul!(C, Ãₚ, A, B, α, β, M, K, Nᵣ)
138141
ploopmul!(gesp(C, (Zero(), Nᵣ)), Ãₚ, gesp(B, (Zero(), Nᵣ)), α, β, M, K, N - Nᵣ)
139142
end

src/memory_buffer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function _use_bcache()
2424
end
2525
return BCache(nothing)
2626
end
27-
@inline _free_bcache!(b::BCache{Nothing}) = reseet_bcache_lock!()
27+
@inline _free_bcache!(::BCache{Nothing}) = reset_bcache_lock!()
2828

2929
_use_bcache(::Nothing) = _use_bcache()
3030
function _use_bcache(i)
@@ -42,5 +42,5 @@ _free_bcache!(b::BCache{UInt}) = (Threads.atomic_xor!(BCACHE_LOCK, one(UInt) <<
4242
Currently not using try/finally in matmul routine, despite locking.
4343
So if it errors for some reason, you may need to manually call `reset_bcache_lock!()`.
4444
"""
45-
@inline reseet_bcache_lock!() = (BCACHE_LOCK[] = zero(UInt); nothing)
45+
@inline reset_bcache_lock!() = (BCACHE_LOCK[] = zero(UInt); nothing)
4646

test/aqua.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@testset "Aqua.jl" begin
2-
Aqua.test_all(Octavian)
2+
Aqua.test_all(Octavian, ambiguities=false)
3+
@test isempty(Test.detect_ambiguities(Octavian))
34
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ include("test_suite_preamble.jl")
1818
@info("Octavian.OCTAVIAN_NUM_TASKS[] is $(Octavian.OCTAVIAN_NUM_TASKS[]) tasks")
1919

2020
Random.seed!(123)
21+
Octavian.debug() = true
2122

2223
include("block_sizes.jl")
2324
include("init.jl")

0 commit comments

Comments
 (0)