Global-Scope Basic-Block Reordering for Instruction Cache Performance
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code layout techniques, such as function-level reordering and data layout optimizations, do not effectively optimize instruction cache performance by reducing cache flushes and unconditional jumps, as they lack a comprehensive approach to reorder basic-blocks at a global scope.
Innovation Solution
A method and system for global-scope basic-block reordering that involves profiling an application to generate a hierarchical locality model, which represents affinities between basic-blocks, and uses this model to reorder the code, thereby reducing cache flushes and improving instruction cache performance.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If function-level reordering and data layout optimizations are applied, then code layout is improved, but instruction cache performance is not sufficiently optimized due to lack of global-scope basic-block reordering
Solution Approach 1:
The patent segments the code into basic-blocks at a global scope, allowing fine-grained reordering of code segments. This segmentation enables the compiler to independently reorder basic-blocks across functions based on their execution patterns, thereby optimizing instruction cache performance without requiring complete code rewriting.
Solution Approach 2:
The patent introduces dynamic code layout by generating multiple possible basic-block orderings and selecting the optimal one based on profiling data. The code layout is not fixed but can be dynamically adjusted at compile-time based on execution characteristics, allowing the system to adapt to different performance requirements.
2Loss of energy
If basic-block reordering is performed at global scope, then cache flushes are reduced, but compilation complexity increases
Solution Approach 1:
The patent performs preliminary profiling of the application to gather execution data before generating the optimized code layout. By collecting execution traces and basic-block call graphs in advance, the system can pre-compute affinity metrics and determine optimal reorderings without adding runtime complexity, thus reducing cache flushes while managing compilation complexity through upfront analysis.
Solution Approach 2:
The patent uses feedback from application profiling to guide the code reordering process. Execution traces and basic-block call patterns provide feedback that feeds into the code generation stage, enabling iterative optimization where the compiler adjusts basic-block orderings based on actual execution characteristics to minimize cache flushes.
3Productivity
If hierarchical locality model is generated based on basic-block affinities, then unconditional jumps are reduced, but profiling and modeling requirements increase
Solution Approach 1:
The patent creates a hierarchical locality model that copies and abstracts the essential affinity relationships between basic-blocks from the execution trace. Instead of working with the complete complex execution data directly, the system generates a simplified model that captures the essential ordering relationships, reducing the complexity of profiling and modeling while maintaining the benefits for reducing unconditional jumps.
Data Source
AI summary
An embodiment method of global scope basic-block reordering includes profiling an application having a source code decomposable into a plurality of basic-blocks. The profiling yields a global basic-block sequence. The method also includes generating a hierarchical locality model according to the global basic-block sequence. The method also includes generating a target code according to the hierarchical locality model.


