Skip to content

UndefinedValueAudit

Sebastian Schmieschek edited this page Aug 12, 2015 · 2 revisions

Undefined Values Audit

HemeLB contains a few different places where a variety of different constant values are used in place of values which are unknown or undefined.

HemeLB's policy is to use the std::numeric_limits<>::max() for this quantity for doubles and floats and signed ints, and to promote unsigned ints to signed ints and use -1 for unsigned ints. In each case, a constant defined in constants.h should be used, rather than the literal value.

The purpose of this page is to audit all existing uses and check them for consistency with the policy, as this has been a bug-generator.

We use the below to look for likely candidates, such as -1.0 or -1 or 1<<30

grep -Rni "1" * | grep -v "Doxyfile" | grep -v 'Make'

And get, after editing out irrelevancies:

Configuration:

SimConfig.cc:      long dummyStress = -1;

Geometry:

GeometryReader.cc:34:        int lExclusions[1] = { 0 };
GeometryReader.cc:56:        topologyRank = -1;
GeometryReader.cc:135:          procForEachBlock[block] = -1;
GeometryReader.cc:522:      readInSite.targetProcessor = -1;
GeometryReader.cc:845:      site_t blockNumber = -1;
GeometryReader.cc:872:              unitForEachBlock[blockNumber] = -1;
GeometryReader.cc:984:          if (neighbourI == -1 || neighbourI == readingResult.blocks.x)
GeometryReader.cc:986:          if (neighbourJ == -1 || neighbourJ == readingResult.blocks.y)
GeometryReader.cc:988:          if (neighbourK == -1 || neighbourK == readingResult.blocks.z)
GeometryReader.cc:993:          // been assigned to a rank (in which case ProcessorRankForEachBlockSite != -1).  ProcessorRankForEachBlockSite
GeometryReader.cc:1184:          firstSiteIndexPerBlock[block] = -1;
GeometryReader.cc:1204:        // because some cores will have -1 for a block (indicating that it has no neighbours on
GeometryReader.cc:1258:            site_t m = -1;
GeometryReader.cc.orig:53:        mTopologyRank = -1;
GeometryReader.cc.orig:138:          procForEachBlock[ii] = -1;
GeometryReader.cc.orig:786:      site_t lBlockNumber = -1;
GeometryReader.cc.orig:813:              unitForEachBlock[lBlockNumber] = -1;
GeometryReader.cc.orig:927:          if (neigh_i == -1 || neigh_i == iGlobLatDat->GetXBlockCount())
GeometryReader.cc.orig:929:          if (neigh_j == -1 || neigh_j == iGlobLatDat->GetYBlockCount())
GeometryReader.cc.orig:931:          if (neigh_k == -1 || neigh_k == iGlobLatDat->GetZBlockCount())
GeometryReader.cc.orig:1134:          firstSiteIndexPerBlock[ii] = -1;
GeometryReader.cc.orig:1154:        // because some cores will have -1 for a block (indicating that it has no neighbours on
GeometryReader.cc.orig:1189:      site_t n = -1;
GeometryReader.cc.orig:1208:            site_t m = -1;
GeometryReader.h:7:#include "D3Q15.h"
GeometryReader.h:26:          targetProcessor(-1), siteData(BIG_NUMBER3), ioletNormal(-1.), ioletDistance(-1.),
GeometryReader.h:27:              wallNormal(NO_VALUE), wallDistance(-1.)
GeometryReader.h:31:            cutDistance[direction] = -1.0;
GeometryReader.h:53:        double cutDistance[D3Q15::NUMVECTORS - 1];
LatticeData.cc:197:                    // If flag is 1, we didn't find a neighbour-proc with the neighbour-site on it
LatticeData.cc:203:                      lNewNeighbour.SharedFCount = 1;
LatticeData.cc:211:                  int l = -1;
LatticeData.cc:218:                      l = 1;
LatticeData.cc:371:      localMaxes[1] = 0;
LatticeData.cc:479:      site_t n = -1;
LatticeData.cc:494:            site_t m = -1;
LatticeData.cc:761:      return i < blockCounts.x && j < blockCounts.y && k < blockCounts.z && i > -1 && j > -1 && k
LatticeData.cc:762:          > -1;
Clone this wiki locally