TL;DR
This paper introduces a novel fine-grained microbenchmarking approach to dissect the previously opaque memory hierarchies of NVIDIA's Fermi, Kepler, and Maxwell GPUs. By revealing detailed cache structures, memory throughput, and latency characteristics, this work provides crucial insights for optimizing GPU software and understanding architectural evolution.
What Problem Does This Paper Address?
Graphics Processing Units (GPUs) offer immense computational power, but their performance is often bottlenecked by their complex memory hierarchies. GPU vendors, however, provide limited public information about these intricate systems. Existing microbenchmarking methods, often adapted from older CPU architectures, struggle to accurately probe the sophisticated memory designs of modern GPUs, leading to a lack of understanding and hindering effective software optimization. This paper aims to bridge this knowledge gap by providing a detailed, fine-grained analysis of the memory hierarchies across three generations of NVIDIA GPUs.
Methods
The core contribution of this paper is a novel "fine-grained P-chase" microbenchmark. Unlike traditional P-chase methods that rely on average memory access latency and make assumptions about cache behavior (like LRU replacement and uniform cache sets), this new approach leverages GPU shared memory to record every single memory access latency. This allows for a much more detailed reconstruction of memory access patterns and the deduction of cache parameters without relying on potentially incorrect assumptions.
The methodology involves:
- Data Initialization: Carefully crafting array initializations to create specific memory access patterns (e.g., uniform stride, non-uniform stride, cache line granularity).
- Fine-grained Timing: Using CUDA's
clock()function to record the latency of individual memory accesses. - Shared Memory Logging: Storing these latencies and the corresponding accessed data indices in shared memory.
- Two-Stage Analysis: A systematic procedure to determine cache size, line size, associativity, and replacement policies by observing cache miss patterns as array sizes and strides are varied.
- Hardware-Specific Overhead Measurement: Accurately accounting for the overhead of timing functions and data dependencies to isolate true memory access latencies.
This approach is applied to investigate various components of the GPU memory hierarchy, including L1/L2 data caches, texture caches, read-only data caches, and Translation Look-Aside Buffers (TLBs).
Datasets
The paper does not explicitly list or introduce traditional "datasets" for training or evaluation. Instead, it utilizes synthetic data structures (arrays) generated and manipulated by its microbenchmarking kernels. The experiments are conducted on three generations of NVIDIA GPUs:
- Fermi: GTX 560Ti (Compute Capability 2.1)
- Kepler: GTX 780 (Compute Capability 3.5)
- Maxwell: GTX 980 (Compute Capability 5.2)
The microbenchmarks themselves, along with the experimental data, are made publicly available.
Key Insights and Ideas
- GPU Caches Deviate from CPU Norms: Modern GPU caches exhibit significant differences from traditional CPU caches, including unequal cache sets, non-traditional replacement policies (not strictly LRU), and specialized data mapping schemes (e.g., for texture caches).
- Maxwell's Shared Memory Optimization: The Maxwell architecture shows a remarkable improvement in shared memory performance, particularly in mitigating the impact of bank conflicts, offering significantly lower latencies compared to Fermi and Kepler.
- TLB and Page Table Complexity: The paper reveals unique page table context switching patterns in Maxwell GPUs, leading to longer latencies for specific access scenarios.
- Hardware Pre-fetching: Evidence of hardware-level pre-fetching from DRAM to L2 cache is observed across all tested platforms.
- Architectural Evolution: A clear evolutionary trend is observed across the three generations, with increasing memory capacity and specialized optimizations, particularly in Kepler, followed by a more conservative, efficiency-focused approach in Maxwell.
- Limitations of Traditional P-chase: The study strongly demonstrates why traditional P-chase methods, relying on average latency and specific assumptions, are insufficient for accurately characterizing modern GPU memory hierarchies.
Key Results
- Cache Structure Details: The paper successfully deduces cache parameters (size, line size, associativity) for various GPU caches, revealing unique structures like the 2D spatial locality optimized mapping in Kepler's texture L1 cache.
- Shared Memory Throughput: Maxwell demonstrates superior shared memory throughput, achieving up to 83.9% of theoretical bandwidth, significantly outperforming Kepler (32.5%) and Fermi (58.7%).
- Shared Memory Latency: While shared memory offers low latency, bank conflicts can drastically increase it. Maxwell significantly reduces this bank conflict latency, making it comparable to L1 data cache latency.
- Global Memory Latency: GTX 780 generally shows the shortest global memory latencies. Maxwell exhibits longer latencies for cold cache misses and page table context switching, but otherwise competitive latencies.
- L2 TLB Structure: A conjectured L2 TLB structure is presented, featuring one large set with 17 entries and six small sets with 8 entries each, indicating unequal set sizes.
Limitations and Future Work
- Shared Memory Size Constraint: The fine-grained P-chase microbenchmark's ability to probe the L2 cache is limited by the available shared memory size on the GPU. This prevented a full characterization of the L2 cache.
- Hardware Pre-fetching Complexity: While hardware pre-fetching was detected, its exact size and behavior were not fully quantified.
- Future Work: The authors suggest that their methodology can be extended to investigate other GPU memory components and architectures. Further research could focus on more deeply understanding the pre-fetching mechanisms and exploring the impact of these memory hierarchy characteristics on real-world applications. The paper also implies that the detailed insights gained can guide future software optimizations and architectural modeling.
Summary updated