2 #ifndef COMMON_DISTUTILS_HPP_ 3 #define COMMON_DISTUTILS_HPP_ 23 #ifdef __WITH__BARRIER__TIMING__ 24 MPI_Barrier(MPI_COMM_WORLD);
26 std::chrono::duration<double> time_span =
27 std::chrono::duration_cast<std::chrono::duration<double>>(
29 double rc = time_span.count();
31 std::cout <<
"toc::" << rank <<
"::" << rc << std::endl;
36 #ifdef __WITH__BARRIER__TIMING__ 37 MPI_Barrier(MPI_COMM_WORLD);
39 std::chrono::duration<double> time_span =
40 std::chrono::duration_cast<std::chrono::duration<double>>(
42 double rc = time_span.count();
49 inline void memusage(
const int myrank, std::string event) {
54 if ((fp = fopen(
"/proc/self/statm",
"r")) == NULL)
return;
55 if (fscanf(fp,
"%*s%ld", &rss) != 1) {
60 int64_t current_proc_mem = (size_t)rss * (
size_t)sysconf(_SC_PAGESIZE);
63 MPI_Reduce(¤t_proc_mem, &allprocmem, 1, MPI_INT64_T, MPI_SUM, 0,
66 INFO <<
event <<
" total rss::" << allprocmem << std::endl;
79 int split = (r < n % p) ? n / p + 1 : n / p;
93 (r < rem) ? r * (n / p + 1) : (rem * (n / p + 1) + ((r - rem) * (n / p)));
96 #endif // COMMON_DISTUTILS_HPP_
int startidx(int n, int p, int r)
Returns the start idx of the current rank r for a global dimension n across p processes.
int itersplit(int n, int p, int r)
The dimension a particular rank holds out of the global dimension n across p processes.
static std::stack< std::chrono::steady_clock::time_point > tictoc_stack
void memusage(const int myrank, std::string event)
Captures the memory usage of every mpi process.