1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 \*---------------------------------------------------------------------------*/
34 #include "IOstreams.H"
36 #include "PackedBoolList.H"
42 template<unsigned nBits>
43 inline void reportInfo()
45 unsigned offset = PackedList<nBits>::packing();
47 unsigned useSHL = ((1u << (nBits * offset)) - 1);
48 unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset));
51 << "PackedList<" << nBits << ">" << nl
52 << " max_value: " << PackedList<nBits>::max_value() << nl
53 << " packing: " << PackedList<nBits>::packing() << nl
54 << " utilization: " << (nBits * offset) << nl;
56 Info<< " Masking:" << nl
57 << " shift << " << unsigned(nBits * offset) << nl
58 << " shift >> " << unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset)
62 Info<< " maskLower: " << PackedList<nBits>::maskLower(PackedList<nBits>::packing())
64 << " useSHL: " << useSHL << nl
65 << " useSHR: " << useSHR << nl;
69 Info<< "WARNING: different results for SHL and SHR" << nl;
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 int main(int argc, char *argv[])
82 argList::noParallel();
83 argList::validArgs.insert("file .. fileN");
85 argList::validOptions.insert("mask", "");
86 argList::validOptions.insert("count", "");
87 argList::validOptions.insert("info", "");
89 argList args(argc, argv, false, true);
92 if (args.optionFound("mask"))
94 Info<< "bit width: " << unsigned(sizeof(unsigned)*CHAR_BIT) << endl;
129 else if (args.additionalArgs().empty())
135 forAll(args.additionalArgs(), argI)
137 const string& srcFile = args.additionalArgs()[argI];
138 Info<< nl << "reading " << srcFile << nl;
140 IFstream ifs(srcFile);
141 List<label> rawLst(ifs);
143 PackedBoolList packLst(rawLst);
145 Info<< "size: " << packLst.size() << nl;
147 if (args.optionFound("count"))
149 unsigned int rawCount = 0;
150 forAll(rawLst, elemI)
157 Info<< "raw count: " << rawCount << nl
158 << "packed count: " << packLst.count() << nl;
161 if (args.optionFound("info"))
167 IOobject::writeDivider(Info);
173 // ************************************************************************* //