36#include <nvbench/nvbench.cuh>
56 void operator()(nvbench::state &st, nvbench::type_list<>)
102 throw std::runtime_error(
"Benchmark state is not set.");
108 nvbench::state *
st_ =
nullptr;
176 template <
typename Func,
typename... Args>
177 nvbench::benchmark_base &
add_nvbench(
const char *name, Func f, Args &&...args)
179 std::tuple<std::decay_t<Args>...> cargs(std::forward<Args>(args)...);
181 auto nvbench_wrapper = [f, cargs = std::move(cargs)](nvbench::state &st)
mutable
184 std::apply([&](
auto &&...unpacked)
185 { f(std::forward<
decltype(unpacked)>(unpacked)...); }, cargs);
190 return nvbench::benchmark_manager::get()
191 .add(std::make_unique<nvbench::benchmark<Callable>>(Callable{std::move(nvbench_wrapper)}))
208 NVBENCH_MAIN_PRINT_PREAMBLE(parser);
209 NVBENCH_MAIN_RUN_BENCHMARKS(parser);
210 NVBENCH_MAIN_PRINT_EPILOGUE(parser);
212 NVBENCH_MAIN_PRINT_RESULTS(parser);
214 NVBENCH_MAIN_FINALIZE();
228 << std::left << comppare::internal::ansi::BOLD
229 <<
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n============= "
230 << comppare::internal::ansi::ITALIC(
"nvbench")
231 <<
" =============\n*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*"
232 << comppare::internal::ansi::BOLD_OFF <<
"\n\n";
234 std::cout <<
"nvbench cmdline arguments:\n";
237 std::cout << std::setw(2) << std::right <<
" "
238 <<
" [" << i <<
"] " << std::quoted(
nvbench_argv[i]) <<
"\n";
241 std::cout << std::left
242 << comppare::internal::ansi::BOLD(
"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*")
258 template <
class InTup,
class OutTup>
281 static std::shared_ptr<Self> inst{
new Self};
300 template <
class Func>
306 return std::apply([&](
auto &&...in_vals) -> nvbench::benchmark_base &
307 {
return std::apply([&](
auto &&...out_vals) -> nvbench::benchmark_base &
309 std::forward<Func>(user_fn),
310 std::forward<
decltype(in_vals)>(in_vals)...,
311 std::forward<
decltype(out_vals)>(out_vals)...); }, outs); }, inputs);
342#define PLUGIN_HOTLOOP_BENCH \
343 auto state_ = comppare::plugin::nvbenchplugin::state::get_state(); \
344 state_->exec([&](nvbench::launch &launch) { hotloop_body(); });
349#define GPU_PLUGIN_HOTLOOP_BENCH PLUGIN_HOTLOOP_BENCH
Argument parser for plugin command-line arguments.
Definition plugin.hpp:107
std::pair< int, char ** > parse(int argc, char **argv)
Definition plugin.hpp:118
Base class for plugins in the ComPPare framework.
Definition plugin.hpp:60
NVBench plugin for the ComPPare framework.
Definition nvbench.hpp:260
comppare::plugin::nvbenchplugin::nvbench_manager nb_
Definition nvbench.hpp:265
nvbench::benchmark_base & register_impl(const std::string &name, Func &&user_fn, const InTup &inputs, OutTup &outs)
Register an implementation with the NVBench plugin.
Definition nvbench.hpp:301
static std::shared_ptr< Self > instance()
Get the singleton instance of the nvbenchPlugin.
Definition nvbench.hpp:279
nvbenchPlugin & operator=(const nvbenchPlugin &)=delete
void initialize(int &argc, char **argv) override
Initialize the NVBench plugin.
Definition nvbench.hpp:322
nvbenchPlugin(const nvbenchPlugin &)=delete
void run() override
Run the registered benchmarks.
Definition nvbench.hpp:332
Manager class for NVBench integration.
Definition nvbench.hpp:119
nvbench_manager()=default
int nvbench_argc
Definition nvbench.hpp:218
void run()
Run the registered benchmarks.
Definition nvbench.hpp:202
nvbench::benchmark_base & add_nvbench(const char *name, Func f, Args &&...args)
Register a benchmark function with NVBench.
Definition nvbench.hpp:177
~nvbench_manager()=default
char ** nvbench_argv
Definition nvbench.hpp:219
void print_benchmark_header()
Print the benchmark header.
Definition nvbench.hpp:224
void initialize(int &argc, char **argv)
Initialize the NVBench library.
Definition nvbench.hpp:134
comppare::plugin::PluginArgParser nvbench_parser_
Argument parser for NVBench.
Definition nvbench.hpp:221
State class to manage the benchmark state.
Definition nvbench.hpp:81
nvbench::state * st_
Definition nvbench.hpp:108
state(const state &)=delete
state & operator=(const state &)=delete
static nvbench::state * get_state()
Definition nvbench.hpp:99
static void set_state(nvbench::state *st)
Definition nvbench.hpp:94
state & operator=(state &&)=delete
static state & instance()
Definition nvbench.hpp:88
Definition nvbench.hpp:45
This file contains the base Plugin class and concept of a valid Plugin class for the ComPPare framewo...
Wrapper for a callable object to be used within NVBench.
Definition nvbench.hpp:53
NvbenchCallable(F _f)
Definition nvbench.hpp:61
NvbenchCallable & operator=(const NvbenchCallable &other)=default
void operator()(nvbench::state &st, nvbench::type_list<>)
Definition nvbench.hpp:56
NvbenchCallable(const NvbenchCallable &other)=default
~NvbenchCallable()=default
NvbenchCallable & operator=(NvbenchCallable &&other)=default
F f
Definition nvbench.hpp:54
NvbenchCallable(NvbenchCallable &&other)=default