Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
sw::universal::Autotuner Class Reference

Autotuner for precision selection. More...

#include <autotuner.hpp>

Public Member Functions

 Autotuner ()
 Default constructor with reasonable defaults.
Autotuner & setAccuracyRequirement (double acc)
 Set accuracy requirement (max relative error).
Autotuner & setEnergyBudget (double budget)
 Set energy budget (factor vs FP32, e.g., 0.5 = 50% of FP32 energy).
Autotuner & enableTiming (bool enable)
 Enable/disable timing measurements.
Autotuner & setIterations (size_t iters)
 Set number of iterations for timing.
template<typename Func>
AutotuneResult tuneUnaryFunction (const std::string &name, Func &&func, const std::vector< double > &test_inputs)
 Tune a unary function (e.g., sqrt, sin, exp) Reference is computed using double precision.
template<typename Func>
AutotuneResult tuneBinaryFunction (const std::string &name, Func &&func, const std::vector< std::pair< double, double > > &test_inputs)
 Tune a binary function (e.g., add, multiply, pow).
template<typename Func>
AutotuneResult tuneReduction (const std::string &name, Func &&func, const std::vector< std::vector< double > > &test_vectors)
 Tune a reduction function (e.g., dot product, sum).

Static Public Member Functions

static std::vector< double > generateTestInputs (double min_val, double max_val, size_t count)
 Generate test inputs for common ranges.
static std::vector< double > generateLogTestInputs (double min_val, double max_val, size_t count)
 Generate logarithmically spaced test inputs.
static std::vector< std::vector< double > > generateTestVectors (size_t num_vectors, size_t vector_size, double min_val=-1.0, double max_val=1.0, uint64_t seed=12345)
 Generate random test vectors for reduction Each call with the same seed produces identical output, and concurrent calls are safe because the RNG is local to the call.

Detailed Description

Autotuner for precision selection.

Constructor & Destructor Documentation

◆ Autotuner()

sw::universal::Autotuner::Autotuner ( )
inline

Default constructor with reasonable defaults.

Member Function Documentation

◆ enableTiming()

Autotuner & sw::universal::Autotuner::enableTiming ( bool enable)
inline

Enable/disable timing measurements.

◆ generateLogTestInputs()

std::vector< double > sw::universal::Autotuner::generateLogTestInputs ( double min_val,
double max_val,
size_t count )
inlinestatic

Generate logarithmically spaced test inputs.

◆ generateTestInputs()

std::vector< double > sw::universal::Autotuner::generateTestInputs ( double min_val,
double max_val,
size_t count )
inlinestatic

Generate test inputs for common ranges.

◆ generateTestVectors()

std::vector< std::vector< double > > sw::universal::Autotuner::generateTestVectors ( size_t num_vectors,
size_t vector_size,
double min_val = -1.0,
double max_val = 1.0,
uint64_t seed = 12345 )
inlinestatic

Generate random test vectors for reduction Each call with the same seed produces identical output, and concurrent calls are safe because the RNG is local to the call.

◆ setAccuracyRequirement()

Autotuner & sw::universal::Autotuner::setAccuracyRequirement ( double acc)
inline

Set accuracy requirement (max relative error).

◆ setEnergyBudget()

Autotuner & sw::universal::Autotuner::setEnergyBudget ( double budget)
inline

Set energy budget (factor vs FP32, e.g., 0.5 = 50% of FP32 energy).

◆ setIterations()

Autotuner & sw::universal::Autotuner::setIterations ( size_t iters)
inline

Set number of iterations for timing.

◆ tuneBinaryFunction()

template<typename Func>
AutotuneResult sw::universal::Autotuner::tuneBinaryFunction ( const std::string & name,
Func && func,
const std::vector< std::pair< double, double > > & test_inputs )
inline

Tune a binary function (e.g., add, multiply, pow).

◆ tuneReduction()

template<typename Func>
AutotuneResult sw::universal::Autotuner::tuneReduction ( const std::string & name,
Func && func,
const std::vector< std::vector< double > > & test_vectors )
inline

Tune a reduction function (e.g., dot product, sum).

◆ tuneUnaryFunction()

template<typename Func>
AutotuneResult sw::universal::Autotuner::tuneUnaryFunction ( const std::string & name,
Func && func,
const std::vector< double > & test_inputs )
inline

Tune a unary function (e.g., sqrt, sin, exp) Reference is computed using double precision.


The documentation for this class was generated from the following file:
  • /home/runner/work/universal/universal/include/sw/universal/utility/autotuner.hpp