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

The analytical model for blocking #10

Open
YingboMa opened this issue May 21, 2020 · 1 comment
Open

The analytical model for blocking #10

YingboMa opened this issue May 21, 2020 · 1 comment

Comments

@YingboMa
Copy link
Owner

julia> using Hwloc
julia> function params(::Type{T}) where T
           micro_m = LoopVectorization.mᵣ * VectorizationBase.pick_vector_width(T)
           micro_n = LoopVectorization.nᵣ
           topology = Hwloc.topology_load()
           l3 = getdatacache(topology, :L3Cache)
           l2 = getdatacache(l3, :L2Cache)
           l1 = getdatacache(l2, :L1Cache)
           l1associativity = l1.attr.associativity
           l1associativity = l1associativity == 0 ? 8 : # assume 8 if unknown
                               l1associativity == -1 ? l1.attr.size ÷ l1.attr.linesize : # fully associative
                               l1associativity
           l1sets = l1.attr.size ÷ (l1.attr.linesize * l1associativity)
           ncachelines_per_panelA = floor(Int, (l1associativity - 1) / (1 + micro_n/micro_m))
           cache_k = ncachelines_per_panelA * l1.attr.linesize * l1sets ÷ (micro_m * sizeof(T))
       end
params (generic function with 1 method)
julia> getdatacache(topology, name) = for t in topology.children
           isdefined(t, :type_) || return nothing
           return t.type_ === name && t.attr.type_ in (:Unified, :Data) ? t : getdatacache(t, name)
       end
getdatacache (generic function with 1 method)
julia> params(Float64)
213
julia> params(Float32)
256

someone may find this code useful.

@chriselrod
Copy link
Collaborator

This is an, uhh, interesting choice

julia> params(Float32)
76

julia> params(Float64)
76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants