Changeset 2420 for XIOS3/trunk/src/mem_checker.cpp
- Timestamp:
- 10/13/22 15:45:43 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS3/trunk/src/mem_checker.cpp
r2419 r2420 1 1 #include "mem_checker.hpp" 2 #include "cxios.hpp" 2 3 #include "mpi.hpp" 3 4 #include <string> … … 5 6 #include <iostream> 6 7 #include <sstream> 7 #include <fstream>8 8 9 9 #include <fcntl.h> … … 20 20 double CMemChecker::vsize_init_=0; 21 21 double CMemChecker::time_init_=0; 22 22 std::ofstream CMemChecker::fout_; 23 int CMemChecker::flush_counter_=1; 24 23 25 CMemChecker::CMemChecker(const std::string& name) : name_(name) 24 26 { … … 64 66 void CMemChecker::logMem( std::string id, bool finalizeLog ) 65 67 { 66 // function get_xios_mem_data() { 67 // return [ 68 // ... 69 // [ "2000-01-01 01:00:10.XXX", "XIOS close context def", 1000], 70 // [ "2000-01-01 01:00:11.XXX", "update timestep" , 1000], 71 // [ "2000-01-01 01:00:15.XXX", "send field" , 2000], 72 // ... 73 // ]; 74 // } 75 76 std::ofstream fout; 68 if ( !CXios::logMemory ) return ; 69 77 70 int rk = 0; 78 71 MPI_Comm_rank( MPI_COMM_WORLD, &rk ); … … 80 73 double mem = getMemRSS(); 81 74 if (!mem) { 82 fout.open( logName ); 83 fout << "time,event,memory" << std::endl; 84 } 85 else 86 { 87 fout.open( logName, std::ios_base::app ); 75 fout_.open( logName ); 76 fout_ << "time,event,memory" << std::endl; 88 77 } 89 78 79 fout_.precision(4); 90 80 // Time format : YYYY-MM-DD HH:MM:SS.XXX -> seconds * 1000. 91 fout << (MPI_Wtime()-time_init_)*1000.<< "," << id << "," << mem/1000000. << std::endl;81 fout_ << (MPI_Wtime()-time_init_) << "," << id << "," << mem/1000000. << std::endl; 92 82 93 fout.close(); 83 if ((MPI_Wtime()-time_init_)>flush_counter_*600.) 84 { 85 fout_.flush(); 86 flush_counter_++; 87 } 88 89 if (finalizeLog) 90 { 91 fout_.close(); 92 } 94 93 } 95 94
Note: See TracChangeset
for help on using the changeset viewer.