Piko: A Design Framework for Programmable Graphics Pipelines

Anjul Patney, Stanley Tzeng, Kerry A. Seitz Jr., John D. OwensarXiv 2014 · DOI · arXiv

TL;DR

Piko is a design framework and compiler that allows developers to build custom, high-performance graphics pipelines by treating spatial binning and scheduling as first-class programmable components. By decoupling the core computation from how work is distributed, Piko enables the creation of complex renderers—like Reyes or hybrid ray tracers—that are portable across both CPUs and GPUs while remaining within striking distance of hand-optimized performance.

What Problem Does This Paper Address?

Standard graphics APIs like OpenGL and Direct3D are incredibly fast because they are baked into hardware, but they are also rigid. If you want to implement a non-standard pipeline—such as a Reyes micropolygon renderer, a voxel-based system, or a custom hybrid of rasterization and ray tracing—you are often forced to write a "software renderer" from scratch.

Writing these software pipelines is a nightmare for performance. Developers must manually manage massive parallelism, complex load balancing, and data locality (keeping related data close together in memory). Furthermore, an implementation optimized for a massively parallel GPU usually won't run efficiently on a multicore CPU. Piko aims to solve this by providing a high-level abstraction that automates these low-level optimization headaches.

Methods

The core of Piko is a new way to describe a graphics pipeline stage. Instead of writing a single monolithic function, a Piko programmer decomposes each stage into three distinct phases:

  1. AssignBin: Defines how an input primitive (like a triangle or a patch) is mapped to a spatial bin (a 2D tile on the screen).
  2. Schedule: Specifies when and where (on which core) a bin should be processed.
  3. Process: Contains the actual functional logic (e.g., shading a pixel or intersecting a ray).
Figure 2: The three phases of a Piko stage. This diagram shows the role of AssignBin, Schedule, and Process in the scan conversion of a list of triangles using two execution cores. Spatial binning helps in (a) extracting load-balanced parallelism by assigning triangles into smaller, more uniform, spatial bins, and (b) preserving spatial locality within each bin by grouping together spatially-local data. The three phases help fine-tune how computation is grouped and scheduled, and this helps quickly explore the optimization space of an implementation.

This description is fed into Pikoc, a compiler built on LLVM. Pikoc analyzes the pipeline's structure and performs several high-level optimizations:

  • Kernel Fusion: It automatically merges adjacent stages into a single execution kernel to keep data in local registers and caches, reducing expensive memory round-trips.
  • Schedule Elimination: If a programmer requests simple load balancing, the compiler can offload the work to the hardware's native scheduler (like CUDA blocks).
  • Static Dependency Resolution: It manages synchronization points (e.g., "don't start shading until the shadow map is done") at compile time.
Figure 1: Piko is a framework for designing and implementing programmable graphics pipelines that can be easily retargeted to different application configurations and architectural targets. Piko’s input is a functional and structural description of the desired graphics pipeline, augmented with a per-stage grouping of computation into spatial bins (or tiles), and a scheduling preference for these bins. Our compiler generates efficient implementations of the input pipeline for multiple architectures and allows the programmer to tweak these implementations using simple changes in the bin configurations and scheduling preferences.

Datasets

The authors evaluated Piko using several standard 3D rendering benchmarks:

  • Rasterization Scenes: Fairy Forest (174K triangles, mixed sizes), Buddha (1.1M tiny triangles), Mecha (254K triangles), and Dragon (871K triangles).
  • Reyes Rendering Scenes: Bigguy and Teapot, used to test the framework's ability to handle irregular, recursive workloads like surface subdivision.

Key Insights and Ideas

  • Binning as a First-Class Citizen: The authors argue that spatial binning isn't just a trick for rasterizers; it's the fundamental way to manage locality in any graphics workload. By making binning programmable, Piko allows developers to prune unnecessary work early.
  • Decoupling Logic from Execution: By separating Process from Schedule, a developer can change how a renderer handles load balancing for a new architecture just by tweaking a few lines of scheduling code, without touching the core rendering math.
  • The Locality vs. Load Balance Trade-off: Piko makes it easy to explore design trade-offs. For example, "fusing" stages improves data locality but can hurt load balancing if some cores finish much faster than others. Piko allows programmers to toggle these strategies to find the "sweet spot" for specific hardware.
Impact of different configurations on performance, showing the trade-offs between fusion and binning.

Key Results

  • Performance: Piko-generated rasterizers achieve real-time performance, typically running about 3–6x slower than cudaraster, which is considered the gold standard for hand-optimized software rasterization on GPUs.
  • Productivity: The Piko Reyes implementation is only 1.37x slower than Micropolis (a heavily tuned, single-GPU research renderer) but is significantly simpler to write, modify, and port to other architectures.
  • Versatility: The authors successfully implemented a wide array of pipelines—including deferred shading, ray tracing, and particle rendering—demonstrating that the framework isn't limited to traditional triangle drawing.

Limitations and Future Work

  • Hardware Specifics: Piko currently lacks an abstraction for managing core-local "shared memory" (scratchpad memory), which is a major reason for the performance gap compared to hand-tuned CUDA code.
  • Binning Dimensions: The current implementation focuses on 2D spatial bins. The authors suggest that extending this to 3D (for voxels) or non-uniform bin sizes could further improve load balancing.
  • Fixed-Function Units: Piko currently implements everything in software. Integrating access to fixed-function hardware (like the hardware rasterizer or texture units) within the Piko abstraction remains an open research challenge.

Summary updated

Abstract

We present Piko, a framework for designing, optimizing, and retargeting implementations of graphics pipelines on multiple architectures. Piko programmers express a graphics pipeline by organizing the computation within each stage into spatial bins and specifying a scheduling preference for these bins. Our compiler, Pikoc, compiles this input into an optimized implementation targeted to a massively-parallel GPU or a multicore CPU. Piko manages work granularity in a programmable and flexible manner, allowing programmers to build load-balanced parallel pipeline implementations, to exploit spatial and producer-consumer locality in a pipeline implementation, and to explore tradeoffs between these considerations. We demonstrate that Piko can implement a wide range of pipelines, including rasterization, Reyes, ray tracing, rasterization/ray tracing hybrid, and deferred rendering. Piko allows us to implement efficient graphics pipelines with relative ease and to quickly explore design alternatives by modifying the spatial binning configurations and scheduling preferences for individual stages, all while delivering real-time performance that is within a factor six of state-of-the-art rendering systems.
BibTeX
@misc{patney2014piko,
  author = {Anjul Patney and Stanley Tzeng and Kerry A. Seitz Jr. and John D. Owens},
  title = {{Piko: A Design Framework for Programmable Graphics Pipelines}},
  year = {2014},
  eprint = {1404.6293},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1404.6293},
}
Figure