1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 \*---------------------------------------------------------------------------*/
33 #include "IOstreams.H"
35 #include "PackedBoolList.H"
41 template<unsigned nBits>
42 inline void reportInfo()
44 unsigned offset = PackedList<nBits>::packing();
46 unsigned useSHL = ((1u << (nBits * offset)) - 1);
47 unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset));
50 << "PackedList<" << nBits << ">" << nl
51 << " max_value: " << PackedList<nBits>::max_value() << nl
52 << " packing: " << PackedList<nBits>::packing() << nl
53 << " utilization: " << (nBits * offset) << nl;
55 Info<< " Masking:" << nl
56 << " shift << " << unsigned(nBits * offset) << nl
57 << " shift >> " << unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset)
61 Info<< " maskLower: " << PackedList<nBits>::maskLower(PackedList<nBits>::packing())
63 << " useSHL: " << useSHL << nl
64 << " useSHR: " << useSHR << nl;
68 Info<< "WARNING: different results for SHL and SHR" << nl;
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 int main(int argc, char *argv[])
81 argList::noParallel();
82 argList::validArgs.insert("file .. fileN");
84 argList::validOptions.insert("mask", "");
85 argList::validOptions.insert("count", "");
86 argList::validOptions.insert("info", "");
88 argList args(argc, argv, false, true);
91 if (args.optionFound("mask"))
93 Info<< "bit width: " << unsigned(sizeof(unsigned)*CHAR_BIT) << endl;
128 else if (args.additionalArgs().empty())
134 forAll(args.additionalArgs(), argI)
136 const string& srcFile = args.additionalArgs()[argI];
137 Info<< nl << "reading " << srcFile << nl;
139 IFstream ifs(srcFile);
140 List<label> rawLst(ifs);
142 PackedBoolList packLst(rawLst);
144 Info<< "size: " << packLst.size() << nl;
146 if (args.optionFound("count"))
148 unsigned int rawCount = 0;
149 forAll(rawLst, elemI)
156 Info<< "raw count: " << rawCount << nl
157 << "packed count: " << packLst.count() << nl;
160 if (args.optionFound("info"))
166 IOobject::writeDivider(Info);
172 // ************************************************************************* //