diff --git a/applications/test/PackedList/Make/options b/applications/test/PackedList/Make/options index e69de29bb2..42da6e3418 100644 --- a/applications/test/PackedList/Make/options +++ b/applications/test/PackedList/Make/options @@ -0,0 +1,7 @@ +/* + check for consistent behaviour with non-optimized code + */ + +EXE_INC = \ + -DFULLDEBUG -g -O0 + diff --git a/applications/test/PackedList/PackedListTest.C b/applications/test/PackedList/PackedListTest.C index 0c8528bd1c..9bf29923fe 100644 --- a/applications/test/PackedList/PackedListTest.C +++ b/applications/test/PackedList/PackedListTest.C @@ -34,9 +34,46 @@ Description #include "IOstreams.H" #include "IFstream.H" #include "PackedBoolList.H" +#include + using namespace Foam; +template +inline void reportInfo() +{ + unsigned offset = PackedList::packing(); + + unsigned useSHL = ((1u << (nBits * offset)) - 1); + unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset)); + + Info<< nl + << "PackedList<" << nBits << ">" << nl + << " max_value: " << PackedList::max_value() << nl + << " packing: " << PackedList::packing() << nl + << " utilization: " << (nBits * offset) << nl; + + Info<< " Masking:" << nl + << " shift << " << unsigned(nBits * offset) << nl + << " shift >> " << unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset) + << nl; + + hex(Info); + Info<< " maskLower: " << PackedList::maskLower(PackedList::packing()) + << nl + << " useSHL: " << useSHL << nl + << " useSHR: " << useSHR << nl; + + if (useSHL != useSHR) + { + Info<< "WARNING: different results for SHL and SHR" << nl; + } + + Info<< nl; + dec(Info); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -45,16 +82,56 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.insert("file .. fileN"); + argList::validOptions.insert("mask", ""); argList::validOptions.insert("count", ""); argList::validOptions.insert("info", ""); argList args(argc, argv, false, true); - if (args.additionalArgs().empty()) + + if (args.optionFound("mask")) + { + Info<< "bit width: " << unsigned(sizeof(unsigned)*CHAR_BIT) << endl; + reportInfo<1>(); + reportInfo<2>(); + reportInfo<3>(); + reportInfo<4>(); + reportInfo<5>(); + reportInfo<6>(); + reportInfo<7>(); + reportInfo<8>(); + reportInfo<9>(); + reportInfo<10>(); + reportInfo<11>(); + reportInfo<12>(); + reportInfo<13>(); + reportInfo<14>(); + reportInfo<15>(); + reportInfo<16>(); + reportInfo<17>(); + reportInfo<18>(); + reportInfo<19>(); + reportInfo<20>(); + reportInfo<21>(); + reportInfo<22>(); + reportInfo<23>(); + reportInfo<24>(); + reportInfo<25>(); + reportInfo<26>(); + reportInfo<27>(); + reportInfo<28>(); + reportInfo<29>(); + reportInfo<30>(); + reportInfo<31>(); + + return 0; + } + else if (args.additionalArgs().empty()) { args.printUsage(); } + forAll(args.additionalArgs(), argI) { const string& srcFile = args.additionalArgs()[argI]; @@ -62,6 +139,7 @@ int main(int argc, char *argv[]) IFstream ifs(srcFile); List