We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent acde702 commit 251a00cCopy full SHA for 251a00c
sklbench/utils/measurement.py
@@ -113,9 +113,15 @@ def enrich_metrics(
113
114
def get_n_from_cache_size():
115
"""Gets `n` size of square matrix that fits into L3 cache"""
116
- l3_size = get_cpu_info()["l3_cache_size"]
+ cache_size = 0
117
+ cpu_info = get_cpu_info()
118
+ # cache reading abibility of cpuinfo is platform dependent
119
+ if "l3_cache_size" in cpu_info:
120
+ cache_size += cpu_info["l3_cache_size"]
121
+ if "l2_cache_size" in cpu_info:
122
+ cache_size += cpu_info["l2_cache_size"] * psutil.cpu_count(logical=False)
123
n_sockets = get_number_of_sockets()
- return ceil(sqrt(n_sockets * l3_size / 8))
124
+ return ceil(sqrt(n_sockets * cache_size / 8))
125
126
127
def flush_cache(n: int = get_n_from_cache_size()):
0 commit comments