Compiler Precision Selection for Shader Performance
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Developers face challenges in improving the performance of graphic shader programs due to the large number of shader programs in games, which affects processing performance and power consumption, and manual conversion to half precision is impractical.
Innovation Solution
A compiler is used to identify computations in shader programs where precision can be lowered without degrading image quality, automatically rewriting computations to half precision while providing notifications for potential precision loss and weighing power consumption benefits.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If manual conversion to half precision is performed, then precision optimization is achieved, but development time and complexity increase significantly
Solution Approach 1:
The compiler automatically performs precision analysis and conversion to half precision without requiring manual intervention from developers. The system self-services by analyzing shader programs, identifying computations suitable for half precision, and generating optimized code automatically, thereby resolving the contradiction between achieving precision optimization and avoiding increased complexity
Solution Approach 2:
The compiler changes the precision parameter of computations from single precision to half precision automatically. By modifying this fundamental parameter through automated analysis and transformation, the system achieves optimization without requiring developers to manually adjust each computation, thus reducing overall complexity
2Productivity
If all computations are converted to half precision, then performance improvement is achieved, but image quality degradation occurs
Solution Approach 1:
The compiler applies half precision selectively to specific computations rather than uniformly to all computations. By analyzing each computation's sensitivity to precision loss, the system applies lower precision only where acceptable and maintains higher precision where image quality depends on it, thus achieving performance improvement without unacceptable quality degradation
Solution Approach 2:
The system performs partial conversion to half precision, converting only those computations that can tolerate the reduced precision without degrading image quality. This partial action approach allows performance benefits to be realized while avoiding the excessive conversion that would cause quality loss
3Reliability
If precision analysis is performed manually, then control over precision loss is achieved, but time consumption increases
Solution Approach 1:
The compiler performs precision analysis automatically as part of its compilation process, eliminating the need for manual analysis by developers. The system self-services by evaluating precision risks, generating reports, and suggesting optimizations without time-consuming manual intervention, thus maintaining reliability while reducing analysis time
Data Source
Figure 1
Figure 2
Figure 3
AI summary
Methods and devices for lowering precision of computations used in shader programs may include receiving program code for a shader program to use with a graphics processing unit (GPU) that supports half precision storage and arithmetic in shader programs. The methods and devices may include performing at least one pass on the program code to select a set of operations within the program code to lower a precision of a plurality of computations used by the set of operations and evaluating a risk of precision loss for lowering the precision to a half precision for each computation of the plurality of computations. The methods and devices may include generating edited program code by rewriting the computation to the half precision in response to the risk of precision loss being a precision loss threshold.