0

I am profiling my code on various CPUs running Windows7 and my results so far suggest that I need to tune a buffer size proportional to the machine's L2CacheSize or L3CacheSize. Is there a way to obtain these parameters from C++?

Erik Olson
  • 1,154
  • 8
  • 18
  • http://stackoverflow.com/questions/1922249/c-cache-aware-programming might be useful – twentylemon Jun 12 '15 at 21:42
  • https://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/ via http://stackoverflow.com/questions/14283171/how-to-receive-l1-l2-l3-cache-size-using-cpuid-instruction-in-x86 is what google told me. Ick! – Yakk - Adam Nevraumont Jun 12 '15 at 21:43

1 Answers1

2

You can use the GetLogicalProcessorInformation function to get that. It returns an array of SYSTEM_LOGICAL_PROCESSOR_INFORMATION structures which contain a CACHE_DESCRIPTOR structure, which provides the cache size information.

Jonathan Potter
  • 36,172
  • 4
  • 64
  • 79