@@ -6,18 +6,18 @@ num_sockets() = static(1)
6
6
_get_num_cores ():: Int = clamp (CpuId. cpucores (), 1 , (get_cpu_threads ()):: Int )
7
7
8
8
let nc = static (_get_num_cores ())
9
- global num_l1cache () = nc
10
- global num_cores () = nc
9
+ global num_l1cache () = nc
10
+ global num_cores () = nc
11
11
end
12
12
let syst = static ((get_cpu_threads ()):: Int )
13
- global sys_threads () = syst
13
+ global sys_threads () = syst
14
14
end
15
15
num_l2cache () = num_l1cache ()
16
16
num_l3cache () = static (1 )
17
17
num_l4cache () = static (0 )
18
18
19
19
const PrecompiledCacheSize = let cs = CpuId. cachesize ()
20
- ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
20
+ ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
21
21
end
22
22
const PrecompiledCacheInclusive = CpuId. cacheinclusive ()
23
23
# cache_inclusive(_) = False()
@@ -39,52 +39,52 @@ cache_size(::Val{S}) where {S} = cache_size(S)
39
39
cache_size (:: StaticInt{S} ) where {S} = cache_size (S)
40
40
41
41
@inline @generated function cache_size (cachesize)
42
- cs = let cs = CpuId. cachesize ()
43
- ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
44
- end
42
+ cs = let cs = CpuId. cachesize ()
43
+ ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
44
+ end
45
45
46
- cache_sizes = map (enumerate (cs)) do (i, csi)
46
+ cache_sizes = map (enumerate (cs)) do (i, csi)
47
47
48
- return :(
49
- if cachesize == $ i
50
- return static ($ csi)
51
- end
52
- )
53
- end
48
+ return :(
49
+ if cachesize == $ i
50
+ return static ($ csi)
51
+ end
52
+ )
53
+ end
54
54
55
- return quote
56
- begin
57
- $ (cache_sizes... )
58
- end
55
+ return quote
56
+ begin
57
+ $ (cache_sizes... )
59
58
end
59
+ end
60
60
61
61
end
62
62
cache_inclusive (:: Val{S} ) where {S} = cache_inclusive (S)
63
63
cache_inclusive (:: StaticInt{S} ) where {S} = cache_inclusive (S)
64
64
65
65
@inline @generated function cache_inclusive (cacheinclusive)
66
- ci = CpuId. cacheinclusive ()
67
-
68
- cache_inclusives = map (enumerate (ci)) do (i, cii)
69
- val = cii != 0
70
- return :(
71
- if cacheinclusive == $ i
72
- return static ($ val)
73
- end
74
- )
75
- end
76
-
77
- if ! isempty (cache_inclusives)
78
- push! (cache_inclusives, :(return False ()))
79
- else
80
- cache_inclusives = [:(return False ())]
81
- end
82
-
83
- return quote
84
- begin
85
- $ (cache_inclusives... )
86
- end
66
+ ci = CpuId. cacheinclusive ()
67
+
68
+ cache_inclusives = map (enumerate (ci)) do (i, cii)
69
+ val = cii != 0
70
+ return :(
71
+ if cacheinclusive == $ i
72
+ return static ($ val)
73
+ end
74
+ )
75
+ end
76
+
77
+ if ! isempty (cache_inclusives)
78
+ push! (cache_inclusives, :(return False ()))
79
+ else
80
+ cache_inclusives = [:(return False ())]
81
+ end
82
+
83
+ return quote
84
+ begin
85
+ $ (cache_inclusives... )
87
86
end
87
+ end
88
88
89
89
90
90
end
93
93
# TODO : implement
94
94
cache_associativity (_) = static (0 )
95
95
96
- cache_type (:: Union{Val{1}, StaticInt{1}} ) = Val {:Data} ()
96
+ cache_type (:: Union{Val{1},StaticInt{1}} ) = Val {:Data} ()
97
97
cache_type (_) = Val {:Unified} ()
98
98
# cache_type(::Union{Val{2},StaticInt{2}}) = Val{:Unified}()
99
99
# cache_type(::Union{Val{3},StaticInt{3}}) = Val{:Unified}()
100
100
let lnsize = static (CpuId. cachelinesize ())
101
- global cache_linesize (_) = lnsize
101
+ global cache_linesize (_) = lnsize
102
102
end
103
103
# cache_size(_) = StaticInt{0}()
104
104
105
105
# cache_size(::Union{Val{3},StaticInt{3}}) = num_cores() * StaticInt{1441792}()
106
106
function _extra_init ()
107
- cs = let cs = CpuId. cachesize ()
108
- ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
109
- end
110
- cs != = PrecompiledCacheSize && _eval_cache_size (cs)
111
- ci = CpuId. cacheinclusive ()
112
- ci != = PrecompiledCacheInclusive && _eval_cache_inclusive (ci)
113
- return nothing
107
+ cs = let cs = CpuId. cachesize ()
108
+ ntuple (i -> i == 3 ? cs[3 ] ÷ _get_num_cores () : cs[i], length (cs))
109
+ end
110
+ cs != = PrecompiledCacheSize && _eval_cache_size (cs)
111
+ ci = CpuId. cacheinclusive ()
112
+ ci != = PrecompiledCacheInclusive && _eval_cache_inclusive (ci)
113
+ return nothing
114
114
end
0 commit comments