ComPPare 1.0.0
Loading...
Searching...
No Matches
comppare::plugin::nvbenchplugin::nvbench_manager Class Reference

Manager class for NVBench integration. More...

#include <nvbench.hpp>

Collaboration diagram for comppare::plugin::nvbenchplugin::nvbench_manager:
[legend]

Public Member Functions

 nvbench_manager ()=default
 
 ~nvbench_manager ()=default
 
void initialize (int &argc, char **argv)
 Initialize the NVBench library.
 
template<typename Func , typename... Args>
nvbench::benchmark_base & add_nvbench (const char *name, Func f, Args &&...args)
 Register a benchmark function with NVBench.
 
void run ()
 Run the registered benchmarks.
 

Private Member Functions

void print_benchmark_header ()
 Print the benchmark header.
 

Private Attributes

int nvbench_argc
 
char ** nvbench_argv
 
comppare::plugin::PluginArgParser nvbench_parser_ {"--nvbench"}
 Argument parser for NVBench.
 

Detailed Description

Manager class for NVBench integration.

This class handles the initialization, registration, and execution of benchmarks using the NVBench library. It provides methods to initialize the library with command-line arguments, register benchmark functions, and run the benchmarks.

Constructor & Destructor Documentation

◆ nvbench_manager()

comppare::plugin::nvbenchplugin::nvbench_manager::nvbench_manager ( )
default

◆ ~nvbench_manager()

comppare::plugin::nvbenchplugin::nvbench_manager::~nvbench_manager ( )
default

Member Function Documentation

◆ add_nvbench()

template<typename Func , typename... Args>
nvbench::benchmark_base & comppare::plugin::nvbenchplugin::nvbench_manager::add_nvbench ( const char *  name,
Func  f,
Args &&...  args 
)
inline

Register a benchmark function with NVBench.

Template Parameters
FuncThe type of the benchmark function.
ArgsThe types of the arguments to the benchmark function.
Parameters
nameThe name of the benchmark.
fThe function/implementation to register.
argsThe arguments to pass to the benchmark function.
Returns
A reference to the registered benchmark.

This helper simplifies registering a benchmark by automatically wrapping the provided function and its arguments into a NVBench-compatible lambda. The lambda sets the current benchmark state and invokes the function with the captured arguments.

Usage example:

void saxpy(int n, float a, const float* x, float* y);
// Register benchmark: equivalent to writing a manual BM_ function
add_nvbench("SAXPY", saxpy, 1<<20, 2.0f, x_data, y_data);
nvbench::benchmark_base & add_nvbench(const char *name, Func f, Args &&...args)
Register a benchmark function with NVBench.
Definition nvbench.hpp:177

This is equivalent to writing a manual NVBench function:

static void BM_SAXPY(nvbench::state &state) {
// setup code here
state.exec([&](nvbench::launch& launch) {
saxpy<<<numBlocks, blockSize>>>(a, d_x, d_y, n);
});
}
NVBENCH_BENCH(BM_SAXPY);
State class to manage the benchmark state.
Definition nvbench.hpp:81

◆ initialize()

void comppare::plugin::nvbenchplugin::nvbench_manager::initialize ( int &  argc,
char **  argv 
)
inline

Initialize the NVBench library.

Parameters
argcThe number of command-line arguments.
argvThe command-line arguments.

This function initializes the NVBench library with the provided command-line arguments. It also prints the benchmark header and recognized arguments to the console.

◆ print_benchmark_header()

void comppare::plugin::nvbenchplugin::nvbench_manager::print_benchmark_header ( )
inlineprivate

Print the benchmark header.

◆ run()

void comppare::plugin::nvbenchplugin::nvbench_manager::run ( )
inline

Run the registered benchmarks.

This function runs all benchmarks that have been registered with the NVBench library. It should be called after all benchmarks have been registered and the library has been initialized.

Member Data Documentation

◆ nvbench_argc

int comppare::plugin::nvbenchplugin::nvbench_manager::nvbench_argc
private

◆ nvbench_argv

char** comppare::plugin::nvbenchplugin::nvbench_manager::nvbench_argv
private

◆ nvbench_parser_

comppare::plugin::PluginArgParser comppare::plugin::nvbenchplugin::nvbench_manager::nvbench_parser_ {"--nvbench"}
private

Argument parser for NVBench.


The documentation for this class was generated from the following file: