Key Factors for Optimal Loop Tiling Size

The ideal tile size for loop tiling is determined by crucial hardware parameters such as L1/L2/L3 cache capacities, cache line size, and data type size, aiming to keep the active data set within the fastest cache level. Factors like the number of loops and potential interference from co-running applications in shared caches also play a role.

The top 3

  1. Top 3 Cache Levels Dictating Tiling Size: The optimal loop tiling size is primarily constrained by the capacities of L1 and L2 caches. L1 caches are the fastest but smallest, typically ranging from 16KB to 64KB per core, while L2 caches are larger, usually 256KB to 1MB per core, offering a crucial balance for data locality.
  2. Cache Line Size: The Data Fetch Unit: Optimal tiling must align with cache line sizes, which are typically 64 bytes on most modern x86-64 and ARM64 processors. This means fetching one byte automatically loads 63 neighboring bytes, enabling efficient spatial locality. Some architectures, like Apple M-series chips or POWER CPUs, use 128-byte cache lines.
  3. Data Element Size: How Many Fit in Cache: The size of individual data elements directly influences the number of items that can fit into a cache line or tile. For instance, a 64-byte cache line can hold 16 `int` or `float` values (4 bytes each) or 8 `double` values (8 bytes each), critically impacting the effective tile dimensions.

Sources

Open the full topic