Functions | Variables
oomph::MemoryUsage Namespace Reference

///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// More...

Functions

void empty_my_memory_usage_file ()
 Function to empty file that records my memory usage in file whose name is specified by My_memory_usage_filename. More...
 
void doc_my_memory_usage (const std::string &prefix_string)
 Doc my memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by My_memory_usage_filename. Data is appended to that file; wipe it with empty_my_memory_usage_file(). Note: This requires getpid() which is defined in unistd.h so if you don't have that we won't build that function! More...
 
void empty_total_memory_usage_file ()
 Function to empty file that records total memory usage in file whose name is specified by Total_memory_usage_filename. More...
 
void doc_total_memory_usage (const std::string &prefix_string)
 Doc total memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by Total_memory_usage_filename. Data is appended to that file; wipe it with empty_memory_usage_file(). More...
 
void empty_memory_usage_files ()
 Function to empty file that records total and local memory usage in appropriate files. More...
 
void doc_memory_usage (const std::string &prefix_string)
 Doc total and local memory usage, prepended by string (which allows identification from where the function is called, say). NOTE: Local memory usage only works if we have unistd.h header. More...
 
void empty_top_file ()
 Function to empty file that records continuous output from top in file whose name is specified by Top_output_filename. More...
 
void run_continous_top (const std::string &comment)
 Start running top continuously and output (append) into file specified by Top_output_filename. Wipe that file with empty_top_file() if you wish. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before starting. More...
 
void stop_continous_top (const std::string &comment)
 Stop running top continuously. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before stopping. More...
 
void insert_comment_to_continous_top (const std::string &comment)
 Insert comment into running continuous top output. More...
 

Variables

bool Suppress_mpi_synchronisation = true
 Boolean to suppress synchronisation of doc memory usage on processors (via mpi barriers). True (i.e. sync is suppressed) by default because not all processors may reach the relevant doc memory usage statements causing the code to hang). More...
 
std::string My_memory_usage_system_string = "ps aux"
 String containing system command that obtains memory usage of all processes. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
bool Bypass_all_memory_usage_monitoring = false
 Bool allowing quick bypassing of ALL operations related to memory usage monitoring – this allows the code to remain "instrumented" without incurring the heavy penalties associated with the system calls and i/o. Default setting: false. More...
 
std::string My_memory_usage_filename = "my_memory_usage.dat"
 String containing name of file in which we document my memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file() More...
 
std::string Total_memory_usage_system_string
 String containing system command that obtains total memory usage. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
std::string Total_memory_usage_filename = "memory_usage.dat"
 String containing name of file in which we document total memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file() More...
 
std::string Top_system_string = "while true; do top -b -n 2 ; done "
 String containing system command that runs "top" (or equivalent) "indefinitely" and writes to file specified in Top_output_filename. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
std::string Top_output_filename = "top_output.dat"
 String containing name of file in which we document "continuous" output from "top" (or equivalent)– you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_top_file() More...
 

Detailed Description

///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////

Namespace with helper functions to assess total memory usage on the fly using system() – details are very machine specific! This just provides the overall machinery with default settings for our own (linux machines). Uses the system command to spawn a command that computes the total memory usage on the machine where this is called. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]

Namespace with helper functions to assess total memory usage on the fly using system() – details are very machine specific! This just provides the overall machinery with default settings for our own (linux machines). Uses the system command to spawn a command that computes the total memory usage on the machine where this is called. [Disclaimer: works on my machine(s) – no guarantees for any other platform; Linux or not. MH]

Function Documentation

◆ doc_memory_usage()

void oomph::MemoryUsage::doc_memory_usage ( const std::string &  prefix_string)

Doc total and local memory usage, prepended by string (which allows identification from where the function is called, say). NOTE: Local memory usage only works if we have unistd.h header.

Doc total and local memory usage, prepended by string (which allows identification from where the function is called, say)

Definition at line 1535 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, doc_my_memory_usage(), and doc_total_memory_usage().

◆ doc_my_memory_usage()

void oomph::MemoryUsage::doc_my_memory_usage ( const std::string &  prefix_string)

Doc my memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by My_memory_usage_filename. Data is appended to that file; wipe it with empty_my_memory_usage_file(). Note: This requires getpid() which is defined in unistd.h so if you don't have that we won't build that function!

Definition at line 1424 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, oomph::MPI_Helpers::communicator_pt(), oomph::MPI_Helpers::mpi_has_been_initialised(), My_memory_usage_filename, My_memory_usage_system_string, and Suppress_mpi_synchronisation.

Referenced by doc_memory_usage().

◆ doc_total_memory_usage()

void oomph::MemoryUsage::doc_total_memory_usage ( const std::string &  prefix_string)

Doc total memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by Total_memory_usage_filename. Data is appended to that file; wipe it with empty_memory_usage_file().

Doc total memory usage, prepended by string (which allows identification from where the function is called, say) that records mem usage in file whose name is specified by Total_memory_usage_filename. Data is appended to that file; wipe it with empty_memory_usage_file().

Definition at line 1489 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, oomph::MPI_Helpers::communicator_pt(), oomph::MPI_Helpers::mpi_has_been_initialised(), Suppress_mpi_synchronisation, Total_memory_usage_filename, and Total_memory_usage_system_string.

Referenced by doc_memory_usage().

◆ empty_memory_usage_files()

void oomph::MemoryUsage::empty_memory_usage_files ( )

Function to empty file that records total and local memory usage in appropriate files.

Definition at line 1522 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, empty_my_memory_usage_file(), empty_top_file(), and empty_total_memory_usage_file().

◆ empty_my_memory_usage_file()

void oomph::MemoryUsage::empty_my_memory_usage_file ( )

Function to empty file that records my memory usage in file whose name is specified by My_memory_usage_filename.

Definition at line 1402 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, and My_memory_usage_filename.

Referenced by empty_memory_usage_files().

◆ empty_top_file()

void oomph::MemoryUsage::empty_top_file ( )

Function to empty file that records continuous output from top in file whose name is specified by Top_output_filename.

Definition at line 1564 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, Top_output_filename, and Top_system_string.

Referenced by empty_memory_usage_files().

◆ empty_total_memory_usage_file()

void oomph::MemoryUsage::empty_total_memory_usage_file ( )

Function to empty file that records total memory usage in file whose name is specified by Total_memory_usage_filename.

Definition at line 1472 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, and Total_memory_usage_filename.

Referenced by empty_memory_usage_files().

◆ insert_comment_to_continous_top()

void oomph::MemoryUsage::insert_comment_to_continous_top ( const std::string &  comment)

Insert comment into running continuous top output.

Definition at line 1680 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, and Top_output_filename.

Referenced by run_continous_top(), and stop_continous_top().

◆ run_continous_top()

void oomph::MemoryUsage::run_continous_top ( const std::string &  comment)

Start running top continuously and output (append) into file specified by Top_output_filename. Wipe that file with empty_top_file() if you wish. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before starting.

Start running top continuously and output (append) into file specified by Top_output_filename. Wipe that file with empty_top_file() first if you wish. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before starting.

Definition at line 1583 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, oomph::MPI_Helpers::communicator_pt(), insert_comment_to_continous_top(), oomph::MPI_Helpers::mpi_has_been_initialised(), oomph::Global_string_for_annotation::string(), Suppress_mpi_synchronisation, Top_output_filename, and Top_system_string.

◆ stop_continous_top()

void oomph::MemoryUsage::stop_continous_top ( const std::string &  comment)

Stop running top continuously. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before stopping.

Definition at line 1641 of file oomph_utilities.cc.

References Bypass_all_memory_usage_monitoring, oomph::MPI_Helpers::communicator_pt(), insert_comment_to_continous_top(), oomph::MPI_Helpers::mpi_has_been_initialised(), oomph::Global_string_for_annotation::string(), Suppress_mpi_synchronisation, and Top_output_filename.

Variable Documentation

◆ Bypass_all_memory_usage_monitoring

bool oomph::MemoryUsage::Bypass_all_memory_usage_monitoring = false

Bool allowing quick bypassing of ALL operations related to memory usage monitoring – this allows the code to remain "instrumented" without incurring the heavy penalties associated with the system calls and i/o. Default setting: false.

Definition at line 1390 of file oomph_utilities.cc.

Referenced by doc_memory_usage(), doc_my_memory_usage(), doc_total_memory_usage(), empty_memory_usage_files(), empty_my_memory_usage_file(), empty_top_file(), empty_total_memory_usage_file(), insert_comment_to_continous_top(), run_continous_top(), and stop_continous_top().

◆ My_memory_usage_filename

std::string oomph::MemoryUsage::My_memory_usage_filename = "my_memory_usage.dat"

String containing name of file in which we document my memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file()

Definition at line 1398 of file oomph_utilities.cc.

Referenced by doc_my_memory_usage(), and empty_my_memory_usage_file().

◆ My_memory_usage_system_string

std::string oomph::MemoryUsage::My_memory_usage_system_string = "ps aux"

String containing system command that obtains memory usage of all processes. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH].

String containing system command that obtains memory usage of all processes. Default assignment for Linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; Linux or not. MH].

Definition at line 1384 of file oomph_utilities.cc.

Referenced by doc_my_memory_usage().

◆ Suppress_mpi_synchronisation

bool oomph::MemoryUsage::Suppress_mpi_synchronisation = true

Boolean to suppress synchronisation of doc memory usage on processors (via mpi barriers). True (i.e. sync is suppressed) by default because not all processors may reach the relevant doc memory usage statements causing the code to hang).

Boolean to suppress synchronisation of doc memory usage on processors (via mpi barriers). True (i.e. sync is is suppressed by default because not all processors may execute the reach the relevant doc memory usage statements causing the code to hang).

Definition at line 1378 of file oomph_utilities.cc.

Referenced by doc_my_memory_usage(), doc_total_memory_usage(), run_continous_top(), and stop_continous_top().

◆ Top_output_filename

std::string oomph::MemoryUsage::Top_output_filename = "top_output.dat"

String containing name of file in which we document "continuous" output from "top" (or equivalent)– you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_top_file()

Definition at line 1560 of file oomph_utilities.cc.

Referenced by empty_top_file(), insert_comment_to_continous_top(), run_continous_top(), and stop_continous_top().

◆ Top_system_string

std::string oomph::MemoryUsage::Top_system_string = "while true; do top -b -n 2 ; done "

String containing system command that runs "top" (or equivalent) "indefinitely" and writes to file specified in Top_output_filename. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH].

String containing system command that runs "top" (or equivalent) "indefinitely" and writes to file specified in Top_output_filename. Default assignment for Linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; Linux or not. MH].

Definition at line 1552 of file oomph_utilities.cc.

Referenced by empty_top_file(), and run_continous_top().

◆ Total_memory_usage_filename

std::string oomph::MemoryUsage::Total_memory_usage_filename = "memory_usage.dat"

String containing name of file in which we document total memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file()

Definition at line 1468 of file oomph_utilities.cc.

Referenced by doc_total_memory_usage(), and empty_total_memory_usage_file().

◆ Total_memory_usage_system_string

std::string oomph::MemoryUsage::Total_memory_usage_system_string
Initial value:
=
"ps aux | awk 'BEGIN{sum=0}{sum+=$4}END{print sum}'"

String containing system command that obtains total memory usage. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH].

String containing system command that obtains total memory usage. Default assignment for Linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; Linux or not. MH].

Definition at line 1459 of file oomph_utilities.cc.

Referenced by doc_total_memory_usage().