MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / WriteCallTrace

Method WriteCallTrace

Src/Base/AMReX_BLProfiler.cpp:965–1161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

963
964
965void BLProfiler::WriteCallTrace(bool bFlushing, bool memCheck) { // ---- write call trace data
966
967 if(memCheck) {
968 int nCT(vCallTrace.size());
969 ParallelDescriptor::ReduceIntMax(nCT);
970 bool doFlush(nCT > traceFlushSize);
971 if(doFlush) {
972 amrex::Print() << "Flushing call traces: nCT traceFlushSize = " << nCT
973 << " " << traceFlushSize << "\n";
974 } else {
975 amrex::Print() << "Bypassing call trace flush, nCT < traceFlushSize: " << nCT
976 << " " << traceFlushSize << "\n";
977 return;
978 }
979 }
980
981 Real wctStart(amrex::second()); // time the timer
982 std::string cdir(blProfDirName);
983 const int myProc = ParallelDescriptor::MyProc();
984 const int nProcs = ParallelDescriptor::NProcs();
985 const int nOutFiles = std::max(1, std::min(nProcs, nProfFiles));
986 std::string cFilePrefix("bl_call_stats");
987 std::string cFileName(cdir + '/' + cFilePrefix + "_D_");
988
989 if( ! blProfDirCreated) {
990 amrex::UtilCreateCleanDirectory(cdir);
991 blProfDirCreated = true;
992 }
993
994 // -------- make sure the set of region names is the same on all processors
995 Vector<std::string> localStrings, syncedStrings;
996 bool alreadySynced;
997 for(std::map<std::string, int>::iterator it = mRegionNameNumbers.begin();
998 it != mRegionNameNumbers.end(); ++it)
999 {
1000 localStrings.push_back(it->first);
1001 }
1002 amrex::SyncStrings(localStrings, syncedStrings, alreadySynced);
1003
1004 if( ! alreadySynced) { // ---- need to remap names and numbers
1005 amrex::Print() << "**** Warning: region names not synced: unsupported.\n";
1006 // unsupported for now
1007 }
1008
1009 if(ParallelDescriptor::IOProcessor()) {
1010 std::string globalHeaderFileName(cdir + '/' + cFilePrefix + "_H");
1011 std::ofstream csGlobalHeaderFile;
1012 csGlobalHeaderFile.open(globalHeaderFileName.c_str(),
1013 std::ios::out | std::ios::trunc);
1014 if( ! csGlobalHeaderFile.good()) {
1015 amrex::FileOpenFailed(globalHeaderFileName);
1016 }
1017 csGlobalHeaderFile << "CallStatsProfVersion " << CallStats::cstatsVersion << '\n';
1018 csGlobalHeaderFile << "NProcs " << nProcs << '\n';
1019 csGlobalHeaderFile << "NOutFiles " << nOutFiles << '\n';
1020
1021 for(std::map<std::string, int>::iterator it = mRegionNameNumbers.begin();
1022 it != mRegionNameNumbers.end(); ++it)

Callers

nothing calls this directly

Calls 15

ReduceIntMaxFunction · 0.85
PrintClass · 0.85
secondFunction · 0.85
IOProcessorFunction · 0.85
ConcatenateFunction · 0.85
CallStatsPatchClass · 0.85
ReadyToWriteMethod · 0.80
SeekPosMethod · 0.80
MyProcFunction · 0.70
NProcsFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected