ForwardCom implements a new localized way of handling numerical errors and exceptions that fits parallel processing and facilitates optimization. Traditional systems have two different methods for detecting errors in floating-point calculations. One way is to use a global flags register that is set when an exception occurs. Another way is to use traps (software interrupts). Both methods were introduced at a time before parallel processing, vector processing, and out-of-order processing became common. They are based on a linear conception of program flow and they have no one-to-one correspondence between cause and effect. These traditional methods do not work well with vector processing and out-of-order processing. If two exceptions occur simultaneously in two different elements of the same vector, then it will be detected as a single exception. If vectors are shorter, then the two exceptions will not occur simultaneously and we will detect two exceptions. This is a problem if we want a program to give exactly the same result regardless of vector lengths.
A further problem with out-of-order processors is that traps have to occur in program order. All instructions must be executed speculatively until it can be ascertained that no preceding instruction will generate a trap. Speculative execution is complicated and costly.
The problems with error handling are explained in more detail in the document Agner Fog: Floating point exception tracking and NaN propagation.
The most efficient solution to the problems of exception detection in parallel data processing is to make the exception status information follow the same path as the data flow. ForwardCom does this in the following way. The detection of each type of floating point exception can be enabled or disabled. An enabled exception will generate a NaN (not a number) that propagates through the subsequent calculations. Such a NaN can be detected in the end result or at any desired intermediate point in the calculations. Each NaN includes a payload, which is a bit pattern indicating the type of exception and information about where it occurred. This method is sure to give the same result regardless of whether data are processed sequentially or in parallel or out-of-order.
Integer overflow and other integer errors cannot be detected in this way because integer variables cannot have NaNs. ForwardCom offers a way of detecting integer errors similar to the NaN propagation method. The integer method is storing operands in vector registers and using extra vector elements to store and propagate error information. This is useful for programming languages that check for integer overflow.
ForwardCom seeks to avoid “undefined” behavior and make sure that every error condition has a predictable outcome. Providing reliable ways to detect numerical errors is important for this goal.
ForwardCom defines a standardized way of sending error messages to the user, independent of the user interface framework. A graphical user interface requires a pop-up message box. A character-oriented user interface needs a message sent to the standard error output. A server application requires an error message to be saved in a log file or sent to the administrator. A standard error message function serves the purpose of sending an error message independent of the user interface. This is useful for programs and library functions that need to work regardless of which user interface framework is used.