Computational scientists have long relied on high-precision arithmetic to accurately solve a wide range of problems, from modeling nuclear reactors to predicting supernova physics to measuring the forces within an atomic nucleus. However, changes to hardware, spurred by the demand for more computing capability and growth in machine learning, have us rethinking the balance between the number of digits needed to perform a given calculation and computational efficiency.
Researchers from Purdue University, Prof. Saurabh Bagchi, and the U.S. Department of Energy’s Lawrence Livermore National Laboratory, Dr. Ignacio Laguna, have taken an essential step toward enabling mixed precision calculations on GPUs through novel automatic tuning methods that can be applied to real-world CUDA programs. For portions of a calculation that do not require full 64-bit double-precision arithmetic, lower precision alternatives may provide enough accuracy. The tradeoff could enable us to solve complex problems faster and at lower energy budgets, thus enabling scientific discoveries that would otherwise remain hidden away from us.
The work (GPUMixer: Performance-Driven Floating-Point Tuning for GPU Scientific Applications) recently won the best paper award at the 33rd ISC High Performance conference held June 16-20, 2019, in Frankfurt and which brought together over 3,500 researchers and commercial users. Another result from the work appeared at the 33rd International Conference on Supercomputing (ICS), held June 26-28, in Phoenix, Ariz.
The challenge that the scientific community has been trying to solve is how do we reduce the precision of the variables in a systematic manner—only those variables that would not degrade the quality of the overall result too much and their precision is reduced to the right level. Several recent changes in the GPU space have created new opportunities for mixed precision arithmetic. GPU manufacturers have begun to include native FP64 (double precision) and FP16 (half precision) arithmetic units inside of their processing units, in addition to FP32 (single precision). As a result, FP64/FP32/FP16 instructions can coexist providing different performance levels, e.g., the ratio of FP64:FP32:FP16 throughput is 1:2:4 in the P100 series of Tesla GPUs. Before the introduction of these processors, mixing FP64 and FP32 instructions had limited performance impact because mixed precision math units were rare.
The research team recently published their breakthrough result on this technical challenge.
- PI Saurabh Bagchi said, “This solution will allow the long-running codes on GPUs, those that do a significant amount of floating-point processing, to use just the right precision of the variables to maximize speedup or alternately minimize energy consumption, and bounding the drop in quality of the output.”
- Laguna said, “This automated approach selects precisions for floating-point arithmetic operations that both improve performance andsatisfy accuracy requirements, without needing the programmer to do the laborious tuning of the precisions.” Purdue students, Pradeep Kotipalli and Ranvijay Singh (now at NVIDIA), and Purdue Research Scientist, Dr. Paul Wood (now at Johns Hopkins University), did a significant part of the technical design and development.
No prior work has support for parallel codes found in GPU programming models as they relied on serial instrumentation or profiling support that does not span the GPU programming and execution model, such as CPU-to-GPU calls. Next, accuracy-centric approaches of the prior work lacked a performance model and simply assumed that minimal precision results in the fastest running time. For example in [figure 1], the objective function was to maximize the number of FP32 variables.
In practice, mixing precision requires casting to satisfy the mathematical operation with the most precise operand. However, casting is an expensive operation (e.g., twice as expensive as FP64 operations in the authors’ target GPU architectures) and therefore reducing precisions may actually increase the execution time. Further, when there are parallel resource pools for FP64 and FP32 (as in several GPU architectures), mixing precision allows for an additional opportunity for parallelism, which prior work ignored. Finally, approaches that solely used online runtime information  suffered from very large search space problems. Consider that there are nfloating point variables that can be tuned and there are 3 precision levels supported by the architecture; then the search space is 3n. In large production-level scientific applications, ncan be very large (hundreds), making this method impractical.
The authors presented AMPT-GA, pronounced “Amp-ed GA”, the first mixed precision optimization system that solves an accuracy-constrained performance maximization problem for GPU programs. AMPT-GA seeks to select the set of precision levels for floating point variables at an application level that maximizes the performance while keeping the introduced error below a tolerable threshold, as defined by the application user. The complete set of assignments of each floating point variable to a precision level is called the Precision Vector (PV) and the optimal PV is the final output of AMPT-GA.
The key insight behind AMPT-GA is that the dynamic search technique through the large space of possible precision vectors is aided by static analysis.Their static analysis identifies groups of variables whose precisions should preferentially be changed together to reduce the performance impact of the precision change of any variable through casting. Such information speeds up the online search through the large search space. Further, considering the irregular nature of the search space, AMPT-GA uses a Genetic Algorithm for the search, which helps avoid local minima that prior approaches such as [2, 3] have a tendency to fall into.
The ISC paper, GPUMixer, presents the first static analysis to identify regions of code in a GPU kernel that are guaranteed to improve performance when mixed-precision is used. While previous approaches can identify mixed-precision code segments that improve performance, they are usually dynamic in nature and require running the application many times. This approach, however, identifies these regions statically, which avoids running the application. GPUMixer also presents the first shadow computation analysis for GPUs, a method that allows estimating the error that is introduced when the precision of specific arithmetic operations is downgraded.
The team has shown the power of AMPT-GA and GPUMixer on several real GPU programs, including LULESH, a DOE’s proxy application that approximates hydrodynamics equations discretely and which has been widely used in the procurement of DOE’s next-generation supercomputers and on DOE’s Co-Design Centers. The evaluation on LULESH, the CoMD proxy application, and on several Rodinia GPU benchmarks demonstrates the practical utility of AMPT-GA and GPUMixer on finding mixed-precision configurations that improve performance and maintain an acceptable level of error.
Looking forward the work is continuing to improve the design of these methods so that even lower precision can be leveraged (e.g., half precision or lower) and better mixed-precision combinations can be found more efficiently.
Link to paper (GPUMixer: Performance-Driven Floating-Point Tuning for GPU Scientific Applications): http://lagunaresearch.org/docs/isc-2019.pdf
Authors: Ignacio Laguna (LLNL), Paul C. Wood (Johns Hopkins Applied Physics Lab), Ranvijay Singh (Nvidia), and Saurabh Bagch (Purdue University)
This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under contract DE-AC52-07NA27344 (Lawrence Livermore National Security, LLC – LLNL-MI-774142).