Runtime Partial Code Specialization for Control Flow Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Static inter-procedural optimization in computer programs is less effective when values used in source code are not known at compile time, as it cannot account for runtime data availability, limiting optimization effectiveness.

Innovation Solution

Implementing partial code specialization at runtime by propagating constant values before execution, generating a specialized version of code that replaces parameter references with constant values, improving control flow and simplifying computation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If static inter-procedural optimization is performed during compilation, then optimization can be performed on the entire program source code, but optimization effectiveness deteriorates when values are not known at compile time

Engineering Contradiction:
Improveoptimization effectivenessVSAvoidcompile time availability of values
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The patent performs partial code specialization at runtime by propagating constant values that are discovered during execution. This preliminary action at runtime complements the compile-time optimization by handling values that become known during program execution, thereby resolving the contradiction between compile-time optimization and runtime value availability.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces dynamic code specialization that adapts to runtime conditions. By analyzing the intermediate representation at runtime and specializing code based on discovered constant values, the system dynamically adjusts optimization based on actual execution context, overcoming the static nature of compile-time optimization.

Inventive Principle:
Principle #15Dynamics

2Productivity

If code specialization is performed at compile time, then constant values can be propagated, but values that are only known at runtime cannot be utilized for optimization

Engineering Contradiction:
Improvecomputation simplificationVSAvoidruntime data availability
Core Design Contradiction:
ProductivityVSAdaptability or versatility

Solution Approach 1:

The system performs preliminary analysis of the intermediate representation at runtime to identify constant values and propagation opportunities before code execution. This preliminary runtime analysis enables computation simplification for values that were not available at compile time, while maintaining the benefits of advance preparation.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent uses an intermediate representation as a mediator between compile-time analysis and runtime execution. This intermediate form allows the system to perform specialization at runtime by analyzing the IR, identifying constant values, and generating specialized code without requiring full recompilation, thus bridging the gap between compile-time and runtime optimization.

Inventive Principle:
Principle #24Intermediary (Mediator)

3Productivity

If the entire program source code is analyzed for optimization, then more information is available for comparison, but the complexity of the optimization process increases

Engineering Contradiction:
Improveoptimization effectivenessVSAvoidoptimization process complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent segments the optimization process into distinct phases: compile-time intermediate representation generation, runtime analysis of the IR, and code specialization. This segmentation allows the system to analyze the entire program for optimization opportunities while managing complexity by handling different aspects at appropriate times rather than all at once.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system performs partial code specialization rather than complete program transformation. By specializing only the portions of code where constant values can be propagated at runtime, the system achieves optimization effectiveness without the excessive complexity of complete program reoptimization, applying optimization selectively where beneficial.

Inventive Principle:
Principle #16Partial or excessive action

Data Source

PatentUS9952843B2Partial program specialization at runtime
Publication Date: 2018.04.24 NVIDIA CORP
  • US9952843B2 patent drawing
  • US9952843B2 patent drawing
  • US9952843B2 patent drawing

AI summary

A solution is proposed for implementing staging in computer programs and code specialization at runtime. Even when values are not known at compile time, many of the values used as parameters for a code section or a function are constant, and are known prior to starting the computation of the algorithm. Embodiments of the claimed subject matter propagate these values just before execution in the same way a compiler would if they were compile time constant, resulting in improved control flow and significant simplification in the computation involved.