These return what the operating system reports is being used by the process so it includes any external packages. It is for a single process if you want the value over a set of processes then use MP_Allreduce() to sum them up.
Barry Here is the code: it is only as reliable as the OS is at reporting the values. #if defined(PETSC_USE_PROCFS_FOR_SIZE) sprintf(proc,"/proc/%d",(int)getpid()); if ((fd = open(proc,O_RDONLY)) == -1) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to access system file %s to get memory usage data",file); if (ioctl(fd,PIOCPSINFO,&prusage) == -1) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_READ,"Unable to access system file %s to get memory usage data",file); *mem = (PetscLogDouble)prusage.pr_byrssize; close(fd); #elif defined(PETSC_USE_SBREAK_FOR_SIZE) *mem = (PetscLogDouble)(8*fd - 4294967296); /* 2^32 - upper bits */ #elif defined(PETSC_USE_PROC_FOR_SIZE) && defined(PETSC_HAVE_GETPAGESIZE) sprintf(proc,"/proc/%d/statm",(int)getpid()); if (!(file = fopen(proc,"r"))) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_FILE_OPEN,"Unable to access system file %s to get memory usage data",proc); if (fscanf(file,"%d %d",&mm,&rss) != 2) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SYS,"Failed to read two integers (mm and rss) from %s",proc); *mem = ((PetscLogDouble)rss) * ((PetscLogDouble)getpagesize()); err = fclose(file); if (err) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SYS,"fclose() failed on file"); #elif defined(PETSC_HAVE_GETRUSAGE) getrusage(RUSAGE_SELF,&temp); #if defined(PETSC_USE_KBYTES_FOR_SIZE) *mem = 1024.0 * ((PetscLogDouble)temp.ru_maxrss); #elif defined(PETSC_USE_PAGES_FOR_SIZE) && defined(PETSC_HAVE_GETPAGESIZE) *mem = ((PetscLogDouble)getpagesize())*((PetscLogDouble)temp.ru_maxrss); #else *mem = temp.ru_maxrss; #endif On May 13, 2014, at 12:13 PM, De Groof, Vincent Frans Maria <[email protected]> wrote: > Hi, > > > I'm investigating the performance of a few different direct solvers and I'd > like to compare the memory requirements of the different solvers and > orderings. I am especially interested in the memory usage necessary to store > the factored matrix. > > I experimented with the PetscMemoryGetCurrentUsage and > PetscMemoryGetMaximumUsage before and after KSPSolve. But these seem to > return the memory usage on 1 process and not the total memory usage. Is this > correct? I also noticed that the difference in maximum memory usage is very > small before and after KSPSolve. Does it register the memory usage in > external packages? > > > > thanks, > Vincent
