1
- use raw_cpuid:: { self , CpuId } ;
1
+ use raw_cpuid:: { self , CpuId , CpuIdReaderNative } ;
2
2
3
3
pub use raw_cpuid:: CacheType ;
4
4
5
5
/// Uses the CPUID family info to detect Zen architecture CPUs.
6
6
///
7
7
/// Data pulled from https://en.wikichip.org/wiki/amd/cpuid.
8
8
#[ inline]
9
- fn amd_is_zen ( cpuid : & CpuId ) -> Option < bool > {
9
+ fn amd_is_zen ( cpuid : & CpuId < CpuIdReaderNative > ) -> Option < bool > {
10
10
let info = cpuid. get_feature_info ( ) ?;
11
11
match ( info. base_family_id ( ) , info. extended_family_id ( ) ) {
12
12
( 0xF , 0x8 ..=0xA ) => Some ( true ) ,
@@ -16,7 +16,11 @@ fn amd_is_zen(cpuid: &CpuId) -> Option<bool> {
16
16
17
17
/// Uses cache parameters to get cache size at a given level with the provided cache type.
18
18
#[ inline]
19
- fn generic_cache_size ( cpuid : CpuId , level : u8 , cache_type : CacheType ) -> Option < usize > {
19
+ fn generic_cache_size (
20
+ cpuid : CpuId < CpuIdReaderNative > ,
21
+ level : u8 ,
22
+ cache_type : CacheType ,
23
+ ) -> Option < usize > {
20
24
cpuid
21
25
. get_cache_parameters ( ) ?
22
26
. filter ( |c| c. level ( ) == level && c. cache_type ( ) == cache_type)
@@ -27,7 +31,11 @@ fn generic_cache_size(cpuid: CpuId, level: u8, cache_type: CacheType) -> Option<
27
31
/// This is computed using tlb info. The values come back in kilobytes, so they are multiplied by
28
32
/// 1024 to give the size in bytes to match the behaviour of other architectures.
29
33
#[ inline]
30
- fn amd_cache_size ( cpuid : CpuId , level : u8 , cache_type : CacheType ) -> Option < usize > {
34
+ fn amd_cache_size (
35
+ cpuid : CpuId < CpuIdReaderNative > ,
36
+ level : u8 ,
37
+ cache_type : CacheType ,
38
+ ) -> Option < usize > {
31
39
match ( level, cache_type) {
32
40
( 1 , CacheType :: Instruction ) => cpuid
33
41
. get_l1_cache_and_tlb_info ( )
@@ -70,7 +78,11 @@ pub fn cache_size(level: u8, cache_type: CacheType) -> Option<usize> {
70
78
71
79
/// Uses cache parameters to get cache line size at a given level with the provided cache type.
72
80
#[ inline]
73
- fn generic_cache_line_size ( cpuid : CpuId , level : u8 , cache_type : CacheType ) -> Option < usize > {
81
+ fn generic_cache_line_size (
82
+ cpuid : CpuId < CpuIdReaderNative > ,
83
+ level : u8 ,
84
+ cache_type : CacheType ,
85
+ ) -> Option < usize > {
74
86
cpuid
75
87
. get_cache_parameters ( ) ?
76
88
. filter ( |cparams| cparams. level ( ) == level && cparams. cache_type ( ) == cache_type)
@@ -81,7 +93,11 @@ fn generic_cache_line_size(cpuid: CpuId, level: u8, cache_type: CacheType) -> Op
81
93
/// This is computed using tlb info. Instruction and data cache line sizes
82
94
/// are available separately for the L1 cache, but only unified is available for L2 and L3 caches.
83
95
#[ inline]
84
- fn amd_cache_line_size ( cpuid : CpuId , level : u8 , cache_type : CacheType ) -> Option < usize > {
96
+ fn amd_cache_line_size (
97
+ cpuid : CpuId < CpuIdReaderNative > ,
98
+ level : u8 ,
99
+ cache_type : CacheType ,
100
+ ) -> Option < usize > {
85
101
match ( level, cache_type) {
86
102
( 1 , CacheType :: Instruction ) => cpuid
87
103
. get_l1_cache_and_tlb_info ( )
0 commit comments