A Compiler-assisted locality aware CTA Mapping Scheme

Lifeng Liu, Meilin Liu, Chongjun WangCATA 2019

Abstract

In modern General-Purpose GPU (GPGPU) architectures, the assignment of work units, known as Cooperative Thread Arrays (CTAs), to hardware cores (Streaming Multiprocessors or SMs) is typically performed in a "locality-blind" manner. This paper presents a compiler-assisted mapping scheme that leverages the polyhedron model to identify data reuse patterns between CTAs. By intelligently mapping CTAs with high data reuse to the same SM, the proposed method reduces redundant off-chip memory accesses and improves L1 cache efficiency. Experimental results demonstrate an average performance speedup of 23.3%, which increases to 56.7% when combined with a programmable warp scheduler.

Introduction

Modern GPUs organize parallel work into grids of CTAs. The hardware scheduler is responsible for distributing these CTAs across available SMs. The default scheduling policy is typically round-robin, which ensures load balancing but ignores potential data locality between adjacent CTAs.

Standard round-robin mapping of CTAs to SMs, which often ignores inter-CTA data locality.

When two CTAs assigned to different SMs require the same data, that data must be fetched twice from the global memory. If these CTAs were instead mapped to the same SM, the data could be fetched once and reused from the local L1 cache. This "inter-CTA" reuse is a significant untapped source of performance in many GPGPU applications, as current hardware often ignores these patterns, leading to unnecessary memory traffic and cache thrashing.

Methodology

The proposed system utilizes a multi-stage compiler-driven approach to optimize CTA placement:

  1. Reuse Analysis: The compiler employs the polyhedron model—a mathematical framework for analyzing nested loops—to formally detect memory addresses accessed by multiple CTAs.
  2. Reuse Distance Calculation: Using Integer Linear Programming (ILP), the system calculates the "reuse distance" along the x and y dimensions of the CTA grid.
  3. Directional Mapping: Based on the reuse analysis, the compiler selects an optimal mapping strategy. For 2D grids, this typically involves mapping blocks along the dimension with the highest reuse (e.g., x-dimension or y-dimension).
Comparison of CTA mapping strategies: (a) default/diagonal, (b) row-major (x-dimension) mapping, and (c) column-major (y-dimension) mapping.
  1. Hardware Integration: A custom API is used to communicate the chosen mapping strategy to the GPU hardware via a specialized register. The compiler automatically inserts this API call before the GPU kernel launches.
  2. Load Balancing: To prevent SM underutilization, a balancing algorithm ensures that CTAs are distributed as evenly as possible while maintaining the desired directional locality.

Evaluation and Results

The scheme was evaluated using the GPGPU-sim simulator, modeling an NVIDIA GTX480 architecture. A suite of eight benchmarks, including matrix multiplication (matmul), 2D convolution (conv), and image processing kernels, was used for testing.

Standalone, the locality-aware CTA mapping achieved an average performance improvement of 23.3% compared to the standard Greedy-Then-Oldest (GTO) scheduler. The most significant gains were observed in kernels like conv and imregionmax, where neighboring blocks share substantial amounts of data.

Furthermore, when paired with a programmable warp scheduler—which manages fine-grained execution order within the SM—the average speedup reached 56.7%. This synergy occurs because the CTA mapping ensures the necessary data is present in the L1 cache, while the warp scheduler ensures that data isn't evicted before it can be reused by other threads. The authors note that if a memory block is reused by $N$ thread blocks, mapping them to the same SM allows for $N-1$ cache hits.

Conclusion

This research highlights the importance of considering inter-CTA locality in GPU scheduling. By moving beyond simple round-robin mapping to a compiler-informed, directional approach, significant reductions in memory traffic and improvements in cache hit rates are possible. While the current implementation requires specific hardware support for programmable mapping, the substantial performance gains suggest that such features would be a valuable addition to future GPU architectures. Future work may explore more complex mapping patterns for 3D grids or irregular memory access patterns.

Summary updated

BibTeX
@inproceedings{liu2019compiler,
  author = {Lifeng Liu and Meilin Liu and Chongjun Wang},
  title = {{A Compiler-assisted locality aware CTA Mapping Scheme}},
  booktitle = {CATA},
  year = {2019},
  doi = {10.29007/55pq},
}
Figure