Error trapping for multiprocessor systems: A primer
last update: 04/29/2003

Introduction to error trapping

On the computers of the last decade, if a code represented numbers with floating-point notation and it performed a useless operation like multiplying two very small numbers or dividing by zero, it produced a result that could not be represented by the computer's internal data format. The computer then "trapped" the error and generated a floating-point exception (FPE).

Trapping involves outputting an error message, taking some action on the erroneous result, then either proceeding with execution or aborting the execution.

Unfortunately, with the multi-pipelined micro-coded floating-point arithmetic units used in computer processors these days, this kind of trapping method is not possible.

When a floating-point exception occurs in these systems, the trap exception sets a register, the non-floating-point bit pattern (a non-number, also called "Not a Number" or NaN) is substituted for the result, and the processor goes on to the next instruction. If the user code does not check for floating-point exceptions, no error message is printed, the computer continues to execute the code, and it usually generates more and more bad numbers. Such a code will often run to completion. The user then examines the results and discovers that they are useless. Further, part of the user's computing resource allocation has been wasted.

Clearly, your time, your GAU allocation, and the computing resources available to the user community are all conserved when your code handles NaNs properly. This primer introduces the IEEE standards for floating-point arithmetic, the different types of NaNs, and how to enable FPE trapping in your code.

By using the simple guidelines in this brief primer, you can design your codes to abort with an error message and a core dump any time a bad number is produced. This primer then explains how to examine the core dump with a debugger to determine why the code produced a useless number.


Next page | Table of contents - TotalView primer

If you have questions about this document, please contact SCD Customer Support. You can also reach us by telephone 24 hours a day, seven days a week at 303-497-1278. Additional contact methods: consult1@ucar.edu and during business hours in NCAR Mesa Lab Suite 39.

© Copyright 2003. University Corporation for Atmospheric Research (UCAR). All Rights Reserved.

Address of this page: http://www.scd.ucar.edu/docs/trap.error/intro.html