Explicit Cast Insertion Transformation: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "fsdfdsfs")
 
No edit summary
Line 1: Line 1:
fsdfdsfs
Code sinking is an optimization technique used in source-to-source compilers to improve execution efficiency by moving computations to less frequently executed parts of the code. This transformation reduces redundant calculations by relocating expressions outside loops or behind conditional statements, thereby minimizing execution overhead. By strategically repositioning code, code sinking enhances performance without altering program behavior.
==Code Sinking Transformation in emmtrix Studio==
emmtrix Studio can implement code sinking using #pragma directives or via the GUI. Code sinking is a transformation that tries to move code parts to valid positions that are executed less often.
===Typical Usage and Benefits===
The transformation is used to optimize the runtime of the application by moving code parts out of loops or behind conditions to reduce the number of times the code is executed.
===Example===
The following code tests code sinking transformation applied to main function.<syntaxhighlight lang="c">
#include <stdio.h>
 
#pragma EMX_TRANSFORMATION CodeSinking
int main(void) {
    int n = 10;
    for (int i = 0; i < 2; ++i) {
        int x = n * n;
        int y = n * n * n;
        int z;
        if (i == 0) {
            z = x;
        } else {
            z = y;
        }
        printf(” % d\ n”, z);
    }
}
</syntaxhighlight>
===Parameters===
Following parameters can be set (each description is followed by keyword in pragma-syntax and default value):
{| class="wikitable"
|+
!Id
!Default Value
!Description
|-
|<code>threshold</code>
|1.45
|'''Threshold''' defines the factor by which the number of executions should be reduced in order for an expressions to be moved;
|-
|<code>conditional</code>
|false
|'''Add conditional variables if necessary''' adds additional if blocks that are required for some code movements
|-
|<code>expected_moved_exprs</code>
| -1
|'''Expected moved expressions''' can be used for testing purposes by inserting the number of expected moved expressions. Creates an error if the numbers differ, does nothing when set to -1;
|}
===Note===
*To move functions from math.h, use the [[Idiom Recognizer]] transformation to identify the functions and apply the code sinking transformation afterwards.
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu