Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions onnxruntime/core/platform/posix/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,19 @@ class PosixEnv : public Env {
}

int GetL2CacheSize() const override {
#ifdef ORT_USE_CPUINFO
Comment thread
tianleiwu marked this conversation as resolved.
Outdated
// Prefer cpuinfo for detection. glibc's aarch64 sysconf backend does not
// implement the cache-size queries, so sysconf(_SC_LEVEL2_CACHE_SIZE)
// returns 0 on Linux/aarch64, which silently disables cache-tiled kernels
// (e.g. CPU FlashAttention in MultiHeadAttention). cpuinfo reads the sizes
// from sysfs cacheinfo and works across architectures.
if (cpuinfo_available_ && cpuinfo_get_l2_caches_count() > 0) {
const auto* l2_cache = cpuinfo_get_l2_cache(0);
if (l2_cache != nullptr && l2_cache->size > 0) {
return static_cast<int>(l2_cache->size);
}
}
Comment on lines +318 to +323
#endif // ORT_USE_CPUINFO
#ifdef _SC_LEVEL2_CACHE_SIZE
return static_cast<int>(sysconf(_SC_LEVEL2_CACHE_SIZE));
#else
Expand Down
Loading