Compiler Hot Function Cloning for Multiversioned Dispatch
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing compiler technologies face inefficiencies due to the overhead of dispatch checks in function multiversioning, which limits optimization and increases runtime overhead, especially for frequently executed functions.
Innovation Solution
The method involves cloning hot functions and hoisting dispatch checks out of them, allowing for direct calls to alternative versions of multiversioned functions, thereby reducing runtime overhead and enabling optimizations across function call boundaries.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If function multiversioning is implemented with dispatch checks at runtime, then platform capability optimization is achieved, but runtime overhead increases
Solution Approach 1:
The compiler performs preliminary analysis to identify hot functions (frequently executed functions) that call multiversioned functions. By pre-determining which functions are hot and need cloning, the system prepares optimized code paths in advance, avoiding the need for runtime dispatch checks in frequently executed code paths.
Solution Approach 2:
The invention segments the code by cloning hot functions into separate versions (first clone and second clone) that each directly call specific versions of the multiversioned function. This segmentation eliminates the need for a single unified dispatch mechanism, allowing each cloned function to have direct, platform-specific calls without runtime overhead.
2Reliability
If dispatch checks are performed at runtime for each function call, then correct version selection is ensured, but code optimization is limited
Solution Approach 1:
The compiler performs preliminary analysis to identify hot functions (frequently executed functions) that call multiversioned functions. By pre-determining which functions are hot and need cloning, the system prepares optimized code paths in advance, avoiding the need for runtime dispatch checks in frequently executed code paths.
Solution Approach 2:
The invention creates copies (clones) of hot functions that directly call specific versions of multiversioned functions. These clones are identical to the original function except for their direct call to a specific version, eliminating the need for runtime dispatch checks while maintaining correct version selection for each code path.
3Adaptability or versatility
If multiple versions of functions are generated for different platforms, then platform-specific optimization is achieved, but executable file size increases
Solution Approach 1:
The invention applies local quality by selectively cloning only hot functions (those that are frequently executed and call multiversioned functions) rather than cloning all functions. This localized approach to multiversioning reduces the overall code size while still providing platform-specific optimization for the most critical code paths.
Solution Approach 2:
Instead of generating complete multiversioned copies of all functions in the program, the system performs partial multiversioning by only cloning hot functions that require platform-specific optimization. This partial action reduces the executable file size while maintaining the benefits of platform-specific optimization for the most important functions.
Data Source
AI summary
Methods, systems, and apparatus, including computer programs encoded on a computer storage medium, for receiving source code that contains a hot function that calls a multiversioned function, where a function definition of the multiversioned function specifies a first version and an alternative second version, and generating compiled code that includes a first and a second clone of the hot function, and a first and a second version of the multiversioned function. In the compiled code, the first clone of the hot function includes a direct call to the first version of the multiversioned function, and the second clone of the hot function includes a direct call to the second version of the multiversioned function.


