TutorialsTutorials HomeDebuggingIntroductionGood Practices Compiler Errors Run-Time Errors Wrong Answers MPI Errors Utilities
FullDocument
Related InfoTotalviewDebugging Tools |
Wrong AnswersOnce the code is compiled and running, the most important question to ask is whether it is giving the correct answers. Checks for this include determining whether energy is conserved or running a test case where the answers are known analytically. If the code fails to give the correct results, then the debugging process must continue. One important point is that the entire parameter space should be tested before the code is declared to be working properly. Often errors don't reveal themselves until the code is run with a given set of input parameters, even though the errors affect the results in all regimes. When it's discovered the code is generating wrong answers, the first thing to determine whether the discrepancy is small or large. These two categories of errors should be approached differently in terms of debugging and will be discussed below. Small Discrepancies from Expected ResultsWhen code that was originally developed on a workstation is ported to a machine at NERSC, there might be slight discrepancies in the results. Another source of small discrepancies between the expected and actual results is optimization. Optimization should always be turned off when the initial debugging is done. If the discrepancy disappears when optimization is turned off, then optimization is obviously the culprit. A few other checks are useful when the code is exhibiting slight deviations from the expected results. The first is the effect of single versus double precision. Another is initialization of variables, which can be checked with compiler options such as:
Large Discrepancies from Expected Results
When large discrepancies exist between the results and the correct answers, the
problem is usually either a logic error in the algorithm or a memory allocation
problem. Correcting logic errors can be facilitated by showing the call tree
in Totalview. Memory allocation problems can often be corrected by invoking
the |
![]() |
Page last modified: Thu, 06 Nov 2003 20:30:24 GMT Page URL: http://www.nersc.gov/nusers/help/tutorials/debug/wrong.php Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |