diff --git a/applications/test/memInfo/Test-memInfo.C b/applications/test/memInfo/Test-memInfo.C index 02823d866f..5dca213db8 100644 --- a/applications/test/memInfo/Test-memInfo.C +++ b/applications/test/memInfo/Test-memInfo.C @@ -40,7 +40,7 @@ using namespace Foam; int main(int argc, char *argv[]) { const int n = 10000000; - const char* const memTags = "peak/size/rss mem: "; + const char* const memTags = "peak/size/rss/free mem: "; memInfo mem; diff --git a/applications/test/sysInfo/Test-sysInfo.C b/applications/test/sysInfo/Test-sysInfo.C index 80ba5c0cdd..8a908fc01e 100644 --- a/applications/test/sysInfo/Test-sysInfo.C +++ b/applications/test/sysInfo/Test-sysInfo.C @@ -30,6 +30,7 @@ Description #include "profilingSysInfo.H" #include "IOstreams.H" #include "endian.H" +#include "cpuInfo.H" using namespace Foam; @@ -38,7 +39,9 @@ using namespace Foam; int main(int argc, char *argv[]) { - profiling::sysInfo().write(Info); + profilingSysInfo().write(Info); + + cpuInfo().write(Info); #ifdef WM_BIG_ENDIAN Info diff --git a/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/files b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/files new file mode 100644 index 0000000000..ba175a6875 --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/files @@ -0,0 +1,3 @@ +profilingSummary.C + +EXE = $(FOAM_APPBIN)/profilingSummary diff --git a/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options new file mode 100644 index 0000000000..4c3dd783cb --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/profilingSummary/Make/options @@ -0,0 +1,3 @@ +EXE_INC = + +EXE_LIBS = diff --git a/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C b/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C new file mode 100644 index 0000000000..2f5e508cc3 --- /dev/null +++ b/applications/utilities/postProcessing/miscellaneous/profilingSummary/profilingSummary.C @@ -0,0 +1,414 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + profilingSummary + +Group + grpMiscUtilities + +Description + Collects information from profiling files in the processor + sub-directories and summarizes the number of calls and time spent as + max/avg/min values. If the values are identical for all processes, + only a single value is written. + +\*---------------------------------------------------------------------------*/ + +#include "Time.H" +#include "polyMesh.H" +#include "OSspecific.H" +#include "IFstream.H" +#include "OFstream.H" +#include "argList.H" +#include "stringOps.H" +#include "timeSelector.H" +#include "IOobjectList.H" + +using namespace Foam; + +// The name of the sub-dictionary entry for profiling fileName: +static const word profilingFileName("profiling"); + +// The name of the sub-dictionary entry for profiling: +static const word blockNameProfiling("profiling"); + +// The name of the sub-dictionary entry for profiling and tags of entries +// that will be processed to determine (max,avg,min) values +const HashTable processing +{ + { "profiling", { "calls", "totalTime", "childTime", "maxMem" } }, + { "memInfo", { "size", "free" } }, +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Collect profiling information from processor directories and\n" + "summarize the time spent and number of calls as (max avg min) values." + ); + + timeSelector::addOptions(true, true); + argList::noParallel(); + argList::noFunctionObjects(); + + // Note that this should work without problems when profiling is active, + // since we don't trigger it anywhere + + #include "setRootCase.H" + #include "createTime.H" + + // Determine the processor count + #ifdef fileOperation_H + const label nProcs = fileHandler().nProcs(args.path()); + #else + label nProcs = 0; + while (isDir(args.path()/(word("processor") + name(nProcs)))) + { + ++nProcs; + } + #endif + + // Create the processor databases + PtrList