|
| void | addErrorMessage (const std::string &message) |
| | Logs an error message through all configured loggers.
|
| void | addLogger (std::unique_ptr< Logging > logger) |
| | Adds a logger for outputting benchmark results.
|
| double | getBaseTime () const |
| | Returns the base time used for speedup calculations.
|
| bool | getCatchExceptions () const |
| | Returns whether exceptions are caught during timing.
|
| SolverMonitorType & | getMonitor () |
| | Returns reference to the solver monitor.
|
| void | setCatchExceptions (bool catchExceptions) |
| | Sets whether to catch exceptions during timing of computations.
|
| void | setDatasetSize (double datasetSize=0.0, double baseTime=0.0) |
| | Sets dataset size and base time for derived metrics.
|
| void | setLoops (std::size_t loops) |
| | Sets the number of iterations for each measurement.
|
| void | setMetadataColumns (const MetadataColumns &metadata) |
| | Sets metadata columns for all subsequent result rows.
|
| void | setMetadataElement (const typename MetadataColumns::value_type &element) |
| | Updates or adds a single metadata element.
|
| void | setMinTime (double minTime) |
| | Sets the minimum runtime for measurements.
|
| void | setOperation (const std::string &operation, double datasetSize=0.0, double baseTime=0.0) |
| | Sets the current operation name and optionally overrides dataset size/base time.
|
| void | setOperationsPerLoop (std::size_t operationsPerLoop) |
| | Sets the number of operations performed per loop iteration.
|
| void | setup (const Config::ParameterContainer ¶meters, const std::string &programName="") |
| | Initializes the benchmark from parsed parameters.
|
| void | setWarmupLoops (std::size_t warmupLoops) |
| | Sets the number of warmup iterations.
|
| void | setWarmupMinTime (double warmupMinTime) |
| | Sets the minimum warmup runtime.
|
| template<typename Device, typename ComputeFunction> |
| BenchmarkResult | time (const std::string &performer, ComputeFunction &compute) |
| | Times a compute function without explicit reset (returns result).
|
| template<typename Device, typename ComputeFunction> |
| void | time (const std::string &performer, ComputeFunction &compute, BenchmarkResult &result) |
| | Times a compute function without explicit reset.
|
| template<typename Device, typename ResetFunction, typename ComputeFunction> |
| BenchmarkResult | time (ResetFunction reset, const std::string &performer, ComputeFunction &compute) |
| | Times a compute function with reset between iterations (returns result).
|
| template<typename Device, typename ResetFunction, typename ComputeFunction> |
| void | time (ResetFunction reset, const std::string &performer, ComputeFunction &compute, BenchmarkResult &result) |
| | Times a compute function with reset between iterations.
|
Base class for running benchmarks with timing and logging support.
The Benchmark class provides a unified interface for measuring performance of computational kernels across different devices (CPU, GPU). It supports:
- Multiple iterations with automatic loop count determination
- Minimum runtime specification for statistical significance
- Automatic warmup iteration before timing begins
- Configurable output logging
- Metadata tracking (device, operation, performer, etc.)
- Bandwidth and speedup calculations
- CPU cycle counting (host devices only)
Example usage:
auto parameters = config.parseCommandLine();
benchmark.
setup( parameters, argv[ 0 ] );
Benchmark::MetadataColumns(
{
} ) );
double datasetSize = size * sizeof( Real ) / oneGB;
auto reset = []() { ... };
auto compute = []() { ... };
benchmark.
time< Device >( reset,
"performer-name", compute );
Base class for running benchmarks with timing and logging support.
Definition Benchmark.h:68
void setup(const Config::ParameterContainer ¶meters, const std::string &programName="")
Initializes the benchmark from parsed parameters.
void setOperation(const std::string &operation, double datasetSize=0.0, double baseTime=0.0)
Sets the current operation name and optionally overrides dataset size/base time.
static void configSetup(Config::ConfigDescription &config)
Configures benchmark-related command line options.
void setMetadataColumns(const MetadataColumns &metadata)
Sets metadata columns for all subsequent result rows.
void time(ResetFunction reset, const std::string &performer, ComputeFunction &compute, BenchmarkResult &result)
Times a compute function with reset between iterations.
Definition ConfigDescription.h:18
std::string getType()
Returns a human-readable string representation of given type.
Definition TypeInfo.h:72
template<typename Device, typename ResetFunction, typename ComputeFunction>
| void TNL::Benchmarks::Benchmark::time |
( |
ResetFunction | reset, |
|
|
const std::string & | performer, |
|
|
ComputeFunction & | compute, |
|
|
BenchmarkResult & | result ) |
Times a compute function with reset between iterations.
Executes the compute function multiple times, calling reset() before each iteration. Results are logged through configured loggers.
One untimed warmup iteration (reset + compute) is performed automatically before the timed loop begins, to stabilize thermal and frequency states and amortize one-time costs such as CUDA JIT compilation.
- Template Parameters
-
| Device | Device type (e.g., TNL::Devices::Host, TNL::Devices::Cuda) |
| ResetFunction | Callable that resets state before each iteration |
| ComputeFunction | Callable containing the code to benchmark |
- Parameters
-
| reset | Function called before each compute iteration |
| performer | Name identifying the implementation being tested |
| compute | Function to benchmark |
| result | Output structure for benchmark results |