Browse Prior Art Database

Phased conditional code loops

IP.com Disclosure Number: IPCOM000195811D
Publication Date: 2010-May-18
Document File: 3 page(s) / 26K

Publishing Venue

The IP.com Prior Art Database

Abstract

Loops are one of the most important software constructs. Loops may be conditional or unconditional - the loop runs until terminated by an external event (interrupt or trap). In many fields of computing, such as High Performance Computing (HPC) for example, many program are dominated by a single loop that may run for long periods of time. The loop will perform its termination test (or tests) countless times even though the developer or user has apriori knowledge of a minimal time period, number of iterations, or conditions that before they occur the loop will not exit.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 52% of the total text.

Page 1 of 3

Loops are one of the most important software constructs. A loop is basically a block of instructions that terminate with a branch back to the beginning of the code block. The loop itself may contain other loops, branches, and function calls. Loops may be conditional - the termination of the code block is based on a test within the block, or unconditional - the loop runs until terminated by an external event (interrupt or trap).

In many fields of computing, such as High Performance Computing (HPC) for example, many program are dominated by a single loop that may run for long periods of time. The loop will perform its termination test (or tests) countless times even though the developer or user has a priory knowledge of a minimal time period, number of iterations, or conditions that before they occur the loop will not exit.

    Thus, computing time, energy, and resources are wasted on testing conditions that are far from being resolved.

Known solution to this problem include:


Have the loop run unconditionally and exit via an interrupt routine when certain conditions occur. Its drawback is that the termination is via an interrupt that might entail OS intervention and degraded performance. In addition the programmer must code, test, and maintain this interrupt handler. This adds to the complexity and overhead of software development and maintenance.

Use a built-in hardware counter that has a very low cost and terminates the loop when it reaches zero. The drawback is that this works for simple loop conditions that have a negligible impact on performance in any case.

Predicate the condition instructions so they should be executed only after a certain amount of time or a specific condition is met. This is similar to the first solution with its drawbacks.

In all cases the building of such loops isn't straightforward.

    Lets look at a basic loop written in the C programming language as an example:
while ( a != 0 && c == 0) {
a = c/b -d[i];
b += a + c*d[i];
if (b > 0) {
c++;
} else {
c = c+d[i];
}
i++;
}

    This loop will iterate until both a is different from 0 and c equals 0. If the user has knowledge that the loop will run for minutes/hours/days without encountering this exit condition, it is worth...