Triumvirate C++ API 0.5.0.post1.dev301+g026f21751
Three-point clustering measurements in large-scale structure analyses.
Loading...
Searching...
No Matches
trv::sys Namespace Reference

Classes

class  ExtrapError
 Exception raised when an extrapolation error occurs. More...
 
class  InvalidDataError
 Exception raised when the data to be operated on are invalid. More...
 
class  InvalidParameterError
 Exception raised when parameters are invalid. More...
 
class  IOError
 Exception raised when an input/output operation fails. More...
 
class  Logger
 Logger with logging level differentiation. More...
 
class  ProgressBar
 Progress bar for tracking tasks. More...
 
class  UnimplementedError
 Exception raised when a function or method is unimplemented. More...
 

Enumerations

enum  LogLevel {
  NSET = 0 , DBUG = 10 , STAT = 20 , INFO = 30 ,
  WARN = 40 , ERRO = 50
}
 Logging levels. More...
 

Functions

bool if_filepath_is_set (const std::string &pathstr)
 Check if a file path is set.
 
void make_write_dir (std::string dirstr)
 Make write directory.
 
bool has_extension (const std::string &fname, const std::string &fext)
 Check if a file has a given extension.
 
std::string join_strings (const std::vector< std::string > &strings, const std::string &delimiter)
 Join a vector of strings with a delimiter.
 
std::vector< std::string > split_string (const std::string &str, const std::string &delimiter)
 Split a string into a vector of strings.
 
template<typename T>
double size_in_gb (long long num)
 Return size in gibibytes.
 
template<typename T>
double size_in_gb (int num)
 Return size in gibibytes.
 
void update_maxmem (bool gpu=false)
 Update the maximum memory usage estimate.
 
void update_maxcntgrid ()
 Update the maximum 3-d grid counts.
 
std::string show_current_datetime (bool utc=false)
 Return the current datetime string.
 
std::string show_elapsed_time (double duration_in_seconds)
 Return the elapsed-time string in 'HH:MM:SS' format.
 
std::string show_timestamp ()
 Return the timestamp string including the elapsed time.
 
int get_gpu_count (bool sys=false)
 Get the number of GPUs available.
 
std::vector< int > get_gpu_ids ()
 Get the indices of GPUs available for use.
 
bool is_gpu_available ()
 Check if GPUs are available in the system.
 
bool is_gpu_enabled ()
 Check if GPU mode is enabled.
 
bool is_gpu_single ()
 Check if in single-GPU mode.
 
void exit_fatal (const std::string &msg)
 Terminate the program with exit status EXIT_FAILURE.
 
bool is_colourable ()
 Check if the program stdout is colourable.
 
std::vector< float > set_nodes_by_str (std::string interval_str)
 Set a node list possibly from a string.
 
std::string get_build_datetime ()
 Return the build datetime string in ISO 8601–like format.
 
void display_help ()
 Display help message in stdout.
 
void display_prog_logo ()
 Display program logo in stdout.
 
void display_prog_licence (bool brief=false)
 Display program licence in stdout.
 
void display_prog_info (bool runtime=false)
 Display program information in stdout.
 
void display_prog_logbars (int endpoint)
 Display program log bars in stdout.
 
void expand_envar_in_path (std::string &path_str)
 Expand environment variables in a path string.
 

Variables

int currTask = 0
 current task
 
double gbytesMem = 0.
 current memory usage in gibibytes
 
double gbytesMaxMem = 0.
 maximum memory usage in gibibytes
 
double gbytesMemGPU = 0.
 current (GPU) memory usage in gibibytes
 
double gbytesMaxMemGPU = 0.
 maximum (GPU) memory usage in gibibytes
 
int count_rgrid = 0
 number of 3-d real grids
 
int count_cgrid = 0
 number of 3-d complex grids
 
float count_grid = 0.
 number of grids
 
int max_count_rgrid = 0
 maximum number of 3-d real grids
 
int max_count_cgrid = 0
 maximum number of 3-d complex grids
 
float max_count_grid = 0.
 maximum number of grids
 
int count_fft = 0
 number of FFTs
 
int count_ifft = 0
 number of IFFTs
 
bool fftw_wisdom_f_imported = false
 wisdom import status for forward transform
 
bool fftw_wisdom_b_imported = false
 wisdom import status for backward transform
 
Logger logger
 default logger (at NSET logging level)
 
auto clockStart = std::chrono::steady_clock::now()
 program starting time
 

Enumeration Type Documentation

◆ LogLevel

Logging levels.

Enumerator
NSET 

0: unset

DBUG 

10: debugging

STAT 

20: status

INFO 

30: info

WARN 

40: warning

ERRO 

50: error/critical

Definition at line 435 of file monitor.hpp.

Function Documentation

◆ if_filepath_is_set()

bool trv::sys::if_filepath_is_set ( const std::string & pathstr)

Check if a file path is set.

Parameters
pathstrFile path string.
Returns
{true, false}

Definition at line 39 of file io.cpp.

+ Here is the caller graph for this function:

◆ make_write_dir()

void trv::sys::make_write_dir ( std::string dirstr)

Make write directory.

Parameters
dirstrDirectory path string.
Exceptions
trv::sys::IOErrorWhen write directory cannot be created.

Definition at line 59 of file io.cpp.

+ Here is the caller graph for this function:

◆ has_extension()

bool trv::sys::has_extension ( const std::string & fname,
const std::string & fext )

Check if a file has a given extension.

Parameters
fnameFile name.
fextFile extension (with the dot).
Returns
{true, false}

Definition at line 38 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ join_strings()

std::string trv::sys::join_strings ( const std::vector< std::string > & strings,
const std::string & delimiter )

Join a vector of strings with a delimiter.

Parameters
stringsA vector of strings.
delimiterDelimiter string.
Returns
Joined string.

Definition at line 45 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ split_string()

std::vector< std::string > trv::sys::split_string ( const std::string & str,
const std::string & delimiter )

Split a string into a vector of strings.

Parameters
strString to be split.
delimiterDelimiter string.
Returns
Vector of strings.

Definition at line 59 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ size_in_gb() [1/2]

template<typename T>
double trv::sys::size_in_gb ( long long num)

Return size in gibibytes.

Template Parameters
TA typename.
Parameters
numNumber of type-double elements.
Returns
Size in gibibytes.

Definition at line 281 of file monitor.hpp.

+ Here is the caller graph for this function:

◆ size_in_gb() [2/2]

template<typename T>
double trv::sys::size_in_gb ( int num)

Return size in gibibytes.

Template Parameters
TA typename.
Parameters
numNumber of type-double elements.
Returns
Size in gibibytes.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 296 of file monitor.hpp.

◆ update_maxmem()

void trv::sys::update_maxmem ( bool gpu = false)

Update the maximum memory usage estimate.

Parameters
gpuIf true, update the GPU memory usage estimate.

Definition at line 165 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ update_maxcntgrid()

void trv::sys::update_maxcntgrid ( )

Update the maximum 3-d grid counts.

Definition at line 177 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ show_current_datetime()

std::string trv::sys::show_current_datetime ( bool utc = false)

Return the current datetime string.

Parameters
utcIf true, return UTC time in ISO 8601–like format, else return local time in 'YYYY-MM-DD HH:MM:SS' format.
Returns
Timestamp string.

Definition at line 189 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ show_elapsed_time()

std::string trv::sys::show_elapsed_time ( double duration_in_seconds)

Return the elapsed-time string in 'HH:MM:SS' format.

Parameters
duration_in_secondsDuration in seconds.
Returns
Elapsed-time string.

Definition at line 212 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ show_timestamp()

std::string trv::sys::show_timestamp ( )

Return the timestamp string including the elapsed time.

Returns
Timestamp string.

Definition at line 238 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_gpu_count()

int trv::sys::get_gpu_count ( bool sys = false)

Get the number of GPUs available.

Parameters
sysIf true, return the number of GPU devices in the system, else return the number of GPU devices available for use.
Returns
int Number of GPUs.
Note
This function checks both the number of GPU devices present and the maximum number available for use as limited by the environmental variable TRV_GPU_MAXNUM.

Definition at line 258 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ get_gpu_ids()

std::vector< int > trv::sys::get_gpu_ids ( )

Get the indices of GPUs available for use.

Returns
GPU indices.

Definition at line 284 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_gpu_available()

bool trv::sys::is_gpu_available ( )

Check if GPUs are available in the system.

Returns
{true, false}

Definition at line 292 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_gpu_enabled()

bool trv::sys::is_gpu_enabled ( )

Check if GPU mode is enabled.

Returns
{true, false}
Note
This function checks if at least one GPU is available for use. It also checks for any override by the environmental variable TRV_GPU_MODE: when it is set to false, no, off or 0, the function will return false.

Definition at line 297 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_gpu_single()

bool trv::sys::is_gpu_single ( )

Check if in single-GPU mode.

Returns
{true, false}

Definition at line 322 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exit_fatal()

void trv::sys::exit_fatal ( const std::string & msg)

Terminate the program with exit status EXIT_FAILURE.

Definition at line 326 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_colourable()

bool trv::sys::is_colourable ( )

Check if the program stdout is colourable.

Returns
{true, false}
Note
true if the environmental variable TRV_INTERACTIVE is set to "true" or "yes" or "1" or "on" and TERM contains "color", or false otherwise.

Definition at line 506 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ set_nodes_by_str()

std::vector< float > trv::sys::set_nodes_by_str ( std::string interval_str)

Set a node list possibly from a string.

If the string corresponds to a number between 0 and 100, that is then the percentage-point interval at which the nodes are set as by ProgressBar::set_nodes().

Parameters
interval_strInterval string.
Returns
Node list.
Exceptions
trv::sys::InvalidParameterErrorIf the interval string is invalid.

Definition at line 649 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ get_build_datetime()

std::string trv::sys::get_build_datetime ( )

Return the build datetime string in ISO 8601–like format.

Returns
Build datetime string.

Definition at line 757 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ display_help()

void trv::sys::display_help ( )

Display help message in stdout.

Definition at line 856 of file monitor.cpp.

+ Here is the caller graph for this function:

◆ display_prog_logo()

void trv::sys::display_prog_logo ( )

Display program logo in stdout.

Definition at line 871 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ display_prog_licence()

void trv::sys::display_prog_licence ( bool brief = false)

Display program licence in stdout.

Parameters
briefDisplay brief notice only (default is false).

Definition at line 890 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ display_prog_info()

void trv::sys::display_prog_info ( bool runtime = false)

Display program information in stdout.

Parameters
runtimeDisplay runtime information (default is false).

Definition at line 930 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ display_prog_logbars()

void trv::sys::display_prog_logbars ( int endpoint)

Display program log bars in stdout.

Parameters
endpointProgress bar endpoint, either 0 (start) or 1 (finish).

Definition at line 994 of file monitor.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expand_envar_in_path()

void trv::sys::expand_envar_in_path ( std::string & path_str)

Expand environment variables in a path string.

Parameters
[in,out]path_strPath string.

Definition at line 1012 of file monitor.cpp.

+ Here is the caller graph for this function:

Variable Documentation

◆ currTask

int trv::sys::currTask = 0

current task

Definition at line 92 of file monitor.cpp.

◆ gbytesMem

double trv::sys::gbytesMem = 0.

current memory usage in gibibytes

Definition at line 94 of file monitor.cpp.

◆ gbytesMaxMem

double trv::sys::gbytesMaxMem = 0.

maximum memory usage in gibibytes

Definition at line 95 of file monitor.cpp.

◆ gbytesMemGPU

double trv::sys::gbytesMemGPU = 0.

current (GPU) memory usage in gibibytes

Definition at line 97 of file monitor.cpp.

◆ gbytesMaxMemGPU

double trv::sys::gbytesMaxMemGPU = 0.

maximum (GPU) memory usage in gibibytes

Definition at line 98 of file monitor.cpp.

◆ count_rgrid

int trv::sys::count_rgrid = 0

number of 3-d real grids

Definition at line 100 of file monitor.cpp.

◆ count_cgrid

int trv::sys::count_cgrid = 0

number of 3-d complex grids

Definition at line 101 of file monitor.cpp.

◆ count_grid

float trv::sys::count_grid = 0.

number of grids

Definition at line 102 of file monitor.cpp.

◆ max_count_rgrid

int trv::sys::max_count_rgrid = 0

maximum number of 3-d real grids

Definition at line 103 of file monitor.cpp.

◆ max_count_cgrid

int trv::sys::max_count_cgrid = 0

maximum number of 3-d complex grids

Definition at line 104 of file monitor.cpp.

◆ max_count_grid

float trv::sys::max_count_grid = 0.

maximum number of grids

Definition at line 105 of file monitor.cpp.

◆ count_fft

int trv::sys::count_fft = 0

number of FFTs

Definition at line 107 of file monitor.cpp.

◆ count_ifft

int trv::sys::count_ifft = 0

number of IFFTs

Definition at line 108 of file monitor.cpp.

◆ fftw_wisdom_f_imported

bool trv::sys::fftw_wisdom_f_imported = false

wisdom import status for forward transform

Definition at line 110 of file monitor.cpp.

◆ fftw_wisdom_b_imported

bool trv::sys::fftw_wisdom_b_imported = false

wisdom import status for backward transform

Definition at line 111 of file monitor.cpp.

◆ logger

Logger trv::sys::logger
extern

default logger (at NSET logging level)

◆ clockStart

auto trv::sys::clockStart = std::chrono::steady_clock::now()

program starting time

Definition at line 113 of file monitor.cpp.