System & Debug

System Info

namespace system

Functions

bool is_metal_available()

Checks if a Metal-capable GPU is available on the system.

Returns:

True if a Metal device is found, false otherwise. This will always be false on non-Apple platforms.

bool should_run_gpu_tests()

Checks if GPU tests should be run.

Returns false if:

  • Metal is not available

  • The AXIOM_SKIP_GPU_TESTS environment variable is set to “1”

Returns:

True if GPU tests should be executed, false otherwise.

std::string device_to_string(Device device)

Threading

namespace parallel

Functions

inline size_t get_num_threads()

Get the maximum number of threads available for parallel regions.

inline void set_num_threads(size_t n)

Set the number of threads for parallel regions (0 = use all available)

inline size_t get_thread_id()

Get the current thread ID within a parallel region.

inline bool should_parallelize(size_t elements, size_t min_elements = DEFAULT_MIN_ELEMENTS)

Check if parallelization would be beneficial for the given element count.

inline bool should_parallelize_reduction(size_t elements)

Check if parallelization would be beneficial for reductions.

inline bool should_parallelize_matmul(size_t M, size_t N, size_t K)

Check if parallelization would be beneficial for matrix multiplication.

Variables

constexpr size_t DEFAULT_MIN_ELEMENTS = 65536
constexpr size_t REDUCTION_MIN_ELEMENTS = 262144
constexpr size_t MATMUL_MIN_PRODUCT = 1000000
class ThreadGuard
#include <parallel.hpp>

RAII guard for temporarily changing the thread count Restores the previous thread count when destroyed.

Public Functions

inline explicit ThreadGuard(size_t)
ThreadGuard(const ThreadGuard&) = delete
ThreadGuard &operator=(const ThreadGuard&) = delete

Tracing

namespace trace

Functions

inline void enable()
inline void disable()
inline void clear()
inline std::string dump()
inline bool is_enabled()
struct TraceEvent
#include <debug.hpp>

Public Members

std::string op_name
std::string description
std::chrono::steady_clock::time_point timestamp
std::chrono::nanoseconds duration
size_t memory_bytes
bool materialized
class Tracer
#include <debug.hpp>

Public Functions

inline void enable()
inline void disable()
inline bool is_enabled() const
inline void clear()
void record(const std::string &op_name, const std::string &desc, std::chrono::nanoseconds duration, size_t memory_bytes, bool materialized)
std::string dump() const
inline const std::vector<TraceEvent> &events() const

Public Static Functions

static Tracer &instance()
class ScopedTrace
#include <debug.hpp>

Public Functions

ScopedTrace(const std::string &op_name, const std::string &desc = "", size_t memory_bytes = 0, bool materialized = false)
~ScopedTrace()

Profiling

namespace profile

Functions

inline void enable()
inline void disable()
inline const OpProfile &last_op()
struct OpProfile
#include <debug.hpp>

Public Members

std::string name
std::chrono::nanoseconds duration
size_t input_bytes
size_t output_bytes
std::string shape_info
class Profiler
#include <debug.hpp>

Public Functions

void record_op(const OpProfile &profile)
inline const OpProfile &last_op() const
inline void enable()
inline void disable()
inline bool is_enabled() const

Public Static Functions

static Profiler &instance()

CPU Info

namespace cpu_info

Functions

void print_simd_info()
const char *simd_arch_name()
std::string simd_info_string()