http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50994
Bug #: 50994
Summary: wanted: interface for querying cache size
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
GCC is missing a way to query cache line size. This could be provided as a
compile-time constant, in the form of predefined macros in a form similar to
the existing sizeof macros via something like __SIZEOF_L1_CACHE_LINE__. Or, it
could be via a __builtin, like __builtin_l1_cache_line_size().
Results would be consistent with existing --param flags, such that
--param l1-cache-line-size=64
meant that
__builtin_l1_cache_line_size() == 64.
I notice that intel provides the following interface, via:
http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/index.htm
unsigned int __cacheSize(unsigned int cacheLevel)
"__cacheSize(n) returns the size in kilobytes of the cache at level n. 1
represents the first-level cache. 0 is returned for a non-existent cache level.
For example, an application may query the cache size and use it to select block
sizes in algorithms that operate on matrices."
ding ding ding!!