# Path: cubical/workers.py
# def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc_threads, max_workers):
# def setup_parallelism(ncpu, nworker, nthread, force_serial, affinity, io_affinity, main_affinity, use_montblanc, montblanc_threads, max_workers):
# def run_process_loop(ms, _tile_list, load_model, single_chunk, solver_type, solver_opts, debug_opts, out_opts):
# def _run_multi_process_loop(ms, load_model, solver_type, solver_opts, debug_opts, out_opts):
#     def reap_children():
# def _run_single_process_loop(ms, load_model, single_chunk, solver_type, solver_opts, debug_opts, out_opts):
# def _init_worker(main=False):
# def _io_handler(save=None, load=None, load_model=True, finalize=False, out_opts=None):
# 
# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]
# 
# Path: cubical/tools/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def disableColors():
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():


from psutil import virtual_memory
from cubical import workers
from cubical.tools import logger, ModColor
    data_points_per_chunk = \
        n_dir*t_per_chunk*f_per_chunk*n_ant*n_ant*n_corr

    # Empirically determined values for the slope and intercept for each
    # solver process.

    w_slope, w_intercept = 5.77281225e-08, 4.53587065e-01

    w_mem_est = w_slope*data_points_per_chunk + w_intercept

    # Empirically determined values for the slope and intercept for the
    # I/O process.

    io_slope, io_intercept = 4.24736385e-08, 3.73958333e-01

    io_mem_est = io_slope*data_points_per_tile + io_intercept

    # Make a guess at the total memory use.

    tot_mem_est = w_mem_est*(workers.num_workers or 1) + io_mem_est

    # Log all of this to terminal.

    print("Detected a total of {:.2f}GiB of system memory.".format(
          tot_sys_mem), file=log)
    print("Per-solver (worker) memory use estimated at {:.2f}GiB: {:.2f}% of "
          "total system memory.".format(w_mem_est, 100*w_mem_est/tot_sys_mem),
          file=log)
    print("Peak I/O memory use estimated at {:.2f}GiB: {:.2f}% of total "
          "system memory.".format(io_mem_est, 100*io_mem_est/tot_sys_mem),

# Path: cubical/workers.py
# def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc_threads, max_workers):
# def setup_parallelism(ncpu, nworker, nthread, force_serial, affinity, io_affinity, main_affinity, use_montblanc, montblanc_threads, max_workers):
# def run_process_loop(ms, _tile_list, load_model, single_chunk, solver_type, solver_opts, debug_opts, out_opts):
# def _run_multi_process_loop(ms, load_model, solver_type, solver_opts, debug_opts, out_opts):
#     def reap_children():
# def _run_single_process_loop(ms, load_model, single_chunk, solver_type, solver_opts, debug_opts, out_opts):
# def _init_worker(main=False):
# def _io_handler(save=None, load=None, load_model=True, finalize=False, out_opts=None):
# 
# Path: cubical/tools/logger.py
# def logToFile(filename, append=False):
# def getLogFilename():
#     def __init__(self, logger, level, color=None, bold=None):
#     def write(self, message, level_override=None, print_once=None):
#     def print(self, *args):
#     def __init__(self, logger, verbose=None, log_verbose=None):
#     def verbosity(self, set_verb=None):
#     def log_verbosity(self, set_verb=None):
#     def __call__(self, level, color=None):
#     def warn(self, msg, color=None, print_once=None):
#     def error(self, msg, color="red", print_once=None):
#     def info(self, msg, color=None, print_once=None):
#     def critical(self, msg, color=None, print_once=None):
#     def debug(self, msg, color=None, print_once=None):
#     def exception(self, msg, color=None, print_once=None):
#     def print(self, *args):
#     def write(self, message, level=logging.INFO, verbosity=0, print_once=None, color=None):
# def enableMemoryLogging(level=1):
# def set_subprocess_label(label):
# def get_subprocess_label():
# def _sigusr1_handler(signum, frame):
# def _sigusr2_handler(signum, frame):
#     def setMemoryLogging(level):
#     def filter(self, event):
#     def __init__(self, fmt, datefmt, strip=True):
#     def label(self, record):
#     def format(self, record):
# def init(app_name):
# def getLogger(name, verbose=None, log_verbose=None):
# def setBoring(boring=True):
# def setGlobalVerbosity(verbosity):
# def setGlobalLogVerbosity(verbosity):
# def setSilent(Lname):
# def setLoud(Lname):
# class _DefaultWriter(object):
# class LoggerWrapper(object):
# class LogFilter(logging.Filter):
# class ColorStrippingFormatter(logging.Formatter):
# GB = float(1024 ** 3)
#                 KEYS = _log_memory_types[memlevel]
# 
# Path: cubical/tools/ModColor.py
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
#     HEADER = ''
#     OKBLUE = ''
#     OKGREEN = ''
#     WARNING = ''
#     FAIL = ''
#     ENDC = ''
# def disableColors():
# def Str(strin0,col="red",Bold=True):
# def Sep(strin=None,D=1):
# def Title(strin,Big=False):
# def disable():


# Path: cubical/data_handler/wisdom.py
from psutil import virtual_memory
from cubical import workers
from cubical.tools import logger, ModColor

    data_points_per_chunk = \
        n_dir*t_per_chunk*f_per_chunk*n_ant*n_ant*n_corr

    # Empirically determined values for the slope and intercept for each
    # solver process.

    w_slope, w_intercept = 5.77281225e-08, 4.53587065e-01

    w_mem_est = w_slope*data_points_per_chunk + w_intercept

    # Empirically determined values for the slope and intercept for the
    # I/O process.

    io_slope, io_intercept = 4.24736385e-08, 3.73958333e-01

    io_mem_est = io_slope*data_points_per_tile + io_intercept

    # Make a guess at the total memory use.

    tot_mem_est = w_mem_est*(workers.num_workers or 1) + io_mem_est

    # Log all of this to terminal.

    print("Detected a total of {:.2f}GiB of system memory.".format(
          tot_sys_mem), file=log)
    print("Per-solver (worker) memory use estimated at {:.2f}GiB: {:.2f}% of "
          "total system memory.".format(w_mem_est, 100*w_mem_est/tot_sys_mem),
          file=log)
    print("Peak I/O memory use estimated at {:.2f}GiB: {:.2f}% of total "
          "system memory.".format(io_mem_est, 100*io_mem_est/tot_sys_mem),

          file=log)