Skip to content

Commit e6f6461

Browse files
committed
have cache_size always refer to per core
1 parent f5315fc commit e6f6461

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CPUSummary"
22
uuid = "2a0fbf3d-bb9c-48f3-b0a9-814d99fd7ab9"
33
authors = ["chriselrod <[email protected]> and contributors"]
4-
version = "0.1.25"
4+
version = "0.1.26"
55

66
[deps]
77
CpuId = "adafc99b-e345-5852-983c-f28acb93d879"

src/CPUSummary.jl

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export cache_size,
3535
# include("generic_topology.jl")
3636
# end
3737
# else
38+
"""
39+
cache_size(::Val{N})
40+
41+
Returns the cache size per core of the `N`th cache
42+
"""
43+
function cache_size end
44+
3845
if (Sys.ARCH === :x86_64)
3946
include("x86.jl")
4047
else

src/x86.jl

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ else
2626
end
2727
num_l4cache() = static(0)
2828

29-
const PrecompiledCacheSize = CpuId.cachesize()
29+
const PrecompiledCacheSize = CpuId.cachesize() (1, 1, CpuId.cpucores())
3030
const PrecompiledCacheInclusive = CpuId.cacheinclusive()
3131
cache_inclusive(_) = False()
3232
@noinline function _eval_cache_size(cachesize)
@@ -56,12 +56,7 @@ cache_size(_) = StaticInt{0}()
5656

5757
# cache_size(::Union{Val{3},StaticInt{3}}) = num_cores() * StaticInt{1441792}()
5858
function _extra_init()
59-
nc = _get_num_cores()
60-
if (nc != CpuId.cpucores())
61-
cache_l3_per_core = CpuId.cachesize(3) ÷ max(CpuId.cpucores(), 1)
62-
@eval cache_size(::Union{Val{3},StaticInt{3}}) = $(static(cache_l3_per_core * nc))
63-
end
64-
cs = CpuId.cachesize()
59+
cs = CpuId.cachesize() (1, 1, CpuId.cpucores())
6560
cs === PrecompiledCacheSize || _eval_cache_size(cs)
6661
ci = CpuId.cacheinclusive()
6762
ci === PrecompiledCacheInclusive || _eval_cache_inclusive(ci)

0 commit comments

Comments
 (0)