pulsatrix
Loading...
Searching...
No Matches
pulsatrix::detail Namespace Reference

Classes

struct  AmdGpuDevice
 One AMD GPU found under <sys_root>/class/drm. More...
 
struct  ASHACandidate
 
struct  CpuTimes
 Aggregate CPU time counters (any consistent unit). busy = total - idle - iowait. More...
 
class  LinuxSources
 Linux /proc + /sys parsers rooted at configurable directories so tests can point them at a fake tree. Pure file parsing: compiles (and is unit-testable) everywhere. More...
 
class  PlatformSources
 Where SystemMonitor reads from. Implementations must make read() thread-safe. More...
 
struct  RawReading
 Raw counters/levels from one platform read; rates are derived by SystemMonitor. More...
 

Functions

std::string module_type_name (const Module &module)
 The dynamic type's readable name (e.g. "pulsatrix::SoftmaxModule"), for error messages.
 
double Sigmoid (double x)
 
double BinomialCoefficient (int64_t n, int64_t k)
 Binomial coefficient C(n,k), computed iteratively to avoid factorial overflow.
 
float ShapKernelWeight (int64_t n, int64_t coalition_size)
 The SHAP kernel pi(z') = (n-1) / [C(n,|z'|) * |z'| * (n-|z'|)], for 1 <= |z'| <= n-1.
 
std::unique_ptr< PlatformSources > make_host_sources ()
 The sources for the host this binary runs on (Linux/Windows + NVML, or a stub).
 
std::optional< double > cpu_percent_from_deltas (const CpuTimes &previous, const CpuTimes &current)
 Utilization in percent from two counter readings; nullopt if no time elapsed.
 
std::string json_escape (const std::string &text)
 JSON string-literal body escaping (quotes, backslash, control characters).
 
std::string format_number (double value)
 Number as a JSON/CSV token: integral values without decimals, else 3 decimals; non-finite -> "".
 
std::string mark_to_json (std::chrono::system_clock::time_point timestamp, double elapsed_seconds, const std::string &label)
 The "event":"mark" JSON Lines record.
 
std::string csv_header (std::size_t gpu_count)
 CSV header for gpu_count GPUs (columns gpu_util, gpu_mem_used, ...).
 
std::string sample_to_csv (const SystemSample &sample, std::size_t gpu_count)
 One CSV data row for sample; GPU columns beyond those present are empty.
 
std::string mark_to_csv (std::chrono::system_clock::time_point timestamp, double elapsed_seconds, const std::string &label, std::size_t gpu_count)
 One CSV mark row (only event, timestamp, elapsed_seconds and label filled).
 

Function Documentation

◆ BinomialCoefficient()

double pulsatrix::detail::BinomialCoefficient ( int64_t  n,
int64_t  k 
)
inline

Binomial coefficient C(n,k), computed iteratively to avoid factorial overflow.

◆ cpu_percent_from_deltas()

std::optional< double > pulsatrix::detail::cpu_percent_from_deltas ( const CpuTimes &  previous,
const CpuTimes &  current 
)

Utilization in percent from two counter readings; nullopt if no time elapsed.

◆ csv_header()

std::string pulsatrix::detail::csv_header ( std::size_t  gpu_count)

CSV header for gpu_count GPUs (columns gpu_util, gpu_mem_used, ...).

◆ format_number()

std::string pulsatrix::detail::format_number ( double  value)

Number as a JSON/CSV token: integral values without decimals, else 3 decimals; non-finite -> "".

◆ json_escape()

std::string pulsatrix::detail::json_escape ( const std::string &  text)

JSON string-literal body escaping (quotes, backslash, control characters).

◆ make_host_sources()

std::unique_ptr< PlatformSources > pulsatrix::detail::make_host_sources ( )

The sources for the host this binary runs on (Linux/Windows + NVML, or a stub).

◆ mark_to_csv()

std::string pulsatrix::detail::mark_to_csv ( std::chrono::system_clock::time_point  timestamp,
double  elapsed_seconds,
const std::string &  label,
std::size_t  gpu_count 
)

One CSV mark row (only event, timestamp, elapsed_seconds and label filled).

◆ mark_to_json()

std::string pulsatrix::detail::mark_to_json ( std::chrono::system_clock::time_point  timestamp,
double  elapsed_seconds,
const std::string &  label 
)

The "event":"mark" JSON Lines record.

◆ module_type_name()

std::string pulsatrix::detail::module_type_name ( const Module &  module)
inline

The dynamic type's readable name (e.g. "pulsatrix::SoftmaxModule"), for error messages.

◆ sample_to_csv()

std::string pulsatrix::detail::sample_to_csv ( const SystemSample &  sample,
std::size_t  gpu_count 
)

One CSV data row for sample; GPU columns beyond those present are empty.

◆ ShapKernelWeight()

float pulsatrix::detail::ShapKernelWeight ( int64_t  n,
int64_t  coalition_size 
)
inline

The SHAP kernel pi(z') = (n-1) / [C(n,|z'|) * |z'| * (n-|z'|)], for 1 <= |z'| <= n-1.

Note
Undefined (division by zero) at |z'|=0 and |z'|=n – those coalitions are handled separately (they anchor f(baseline) and f(x) exactly), never passed here.

◆ Sigmoid()

double pulsatrix::detail::Sigmoid ( double  x)
inline