Skip to content

cpuinfo reports incorrect L2 cache size on ARM (Neoverse V1/V2) #369

@Radu2k

Description

@Radu2k

🐛 Describe the bug

cpuinfo reports incorrect L2 cache size on ARM (Neoverse V1/V2)
Downstream users relying on cpuinfo via PyTorch get under-reported L2 sizes on these ARM platforms (could affect tuning/allocations).

#include <cstddef>
#include <cstdio>
#include <cpuinfo.h>
size_t l2_bytes() {
  if (!cpuinfo_initialize()) return 0;
  const cpuinfo_processor* p = cpuinfo_get_current_processor();
  if (!p || !p->cache.l2) return 0;
  return p->cache.l2->size; // bytes
}
int main() { std::printf("%zu\n", l2_bytes()); }

g++ -O2 -std=c++17 l2c_test.cpp -I"$PYTORCH_ROOT/third_party/cpuinfo/include" -L"$PYTORCH_ROOT/build/lib" -lcpuinfo -lpthread -o l2c_test

  • Observed:
    • Graviton3 (Neoverse V1, expected 1 MiB per core): program prints 262144 bytes (256 KB) for the current processor.
    • Graviton4 (Neoverse V2, expected 2 MiB per core): program prints 1048576 bytes (1 MiB).
  • Expected:
    • Graviton3: ~1 MiB per core.
    • Graviton4: ~2 MiB per core.

Versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions