CPUCache (Windows): detect cache line size

This commit is contained in:
李通洲
2024-06-05 15:44:36 +08:00
parent 00f7334a3a
commit 84c2564c54
3 changed files with 6 additions and 4 deletions
+4 -2
View File
@@ -14,6 +14,7 @@ typedef struct FFCPUCache
{
uint32_t size;
uint32_t num;
uint32_t lineSize;
FFCPUCacheType type;
} FFCPUCache;
@@ -24,13 +25,13 @@ typedef struct FFCPUCacheResult
const char* ffDetectCPUCache(FFCPUCacheResult* result);
static inline FFCPUCache* ffCPUCacheAddItem(FFCPUCacheResult* result, uint32_t level, uint32_t size, FFCPUCacheType type)
static inline FFCPUCache* ffCPUCacheAddItem(FFCPUCacheResult* result, uint32_t level, uint32_t size, uint32_t lineSize, FFCPUCacheType type)
{
FFlist* cacheLevel = &result->caches[level - 1];
FF_LIST_FOR_EACH(FFCPUCache, item, *cacheLevel)
{
if (item->type == type && item->size == size)
if (item->type == type && item->size == size && item->lineSize == lineSize)
{
item->num++;
return item;
@@ -41,6 +42,7 @@ static inline FFCPUCache* ffCPUCacheAddItem(FFCPUCacheResult* result, uint32_t l
*item = (FFCPUCache) {
.size = size,
.num = 1,
.lineSize = lineSize,
.type = type,
};
return item;
+1 -2
View File
@@ -33,8 +33,7 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result)
case CacheTrace: cacheType = FF_CPU_CACHE_TYPE_TRACE; break;
default: __builtin_unreachable(); break;
}
ffCPUCacheAddItem(result, ptr->Cache.Level, ptr->Cache.CacheSize, cacheType);
ffCPUCacheAddItem(result, ptr->Cache.Level, ptr->Cache.CacheSize, ptr->Cache.LineSize, cacheType);
}
}
+1
View File
@@ -122,6 +122,7 @@ void ffGenerateCPUCacheJsonResult(FF_MAYBE_UNUSED FFCPUCacheOptions* options, yy
case FF_CPU_CACHE_TYPE_UNIFIED: typeStr = "unified"; break;
case FF_CPU_CACHE_TYPE_TRACE: typeStr = "trace"; break;
}
yyjson_mut_obj_add_uint(doc, item, "lineSize", src->lineSize);
yyjson_mut_obj_add_str(doc, item, "type", typeStr);
}
}