Add getMemoryUsage function, detection update moved in abstract lass, splitted execution time in pre-inf-post, other minors.
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
@@ -168,3 +168,36 @@ void matrixMulAdd( cublasHandle_t handle, dnnType* srcData, dnnType* dstData,
|
||||
checkERROR( cublasSaxpy(handle, dim, &alpha, srcData, 1, dstData, 1));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void getMemUsage(double& vm_usage_kb, double& resident_set_kb)
|
||||
{
|
||||
using std::ios_base;
|
||||
using std::ifstream;
|
||||
using std::string;
|
||||
|
||||
vm_usage_kb = 0.0;
|
||||
resident_set_kb = 0.0;
|
||||
|
||||
ifstream stat_stream("/proc/self/stat",ios_base::in);
|
||||
|
||||
//all the stats
|
||||
string pid, comm, state, ppid, pgrp, session, tty_nr;
|
||||
string tpgid, flags, minflt, cminflt, majflt, cmajflt;
|
||||
string utime, stime, cutime, cstime, priority, nice;
|
||||
string O, itrealvalue, starttime;
|
||||
|
||||
unsigned long vsize;
|
||||
long rss;
|
||||
|
||||
stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
|
||||
>> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
|
||||
>> utime >> stime >> cutime >> cstime >> priority >> nice
|
||||
>> O >> itrealvalue >> starttime >> vsize >> rss;
|
||||
|
||||
stat_stream.close();
|
||||
|
||||
long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages
|
||||
vm_usage_kb = vsize / 1024.0;
|
||||
resident_set_kb = rss * page_size_kb;
|
||||
}
|
||||
Reference in New Issue
Block a user