diff --git a/examples/custom_criterion.cu b/examples/custom_criterion.cu index 6d1dfb3..3257971 100644 --- a/examples/custom_criterion.cu +++ b/examples/custom_criterion.cu @@ -24,14 +24,14 @@ // Thrust vectors simplify memory management: #include -// Inherit from the stopping_criterion class: -class fixed_criterion final : public nvbench::stopping_criterion +// Inherit from the stopping_criterion_base class: +class fixed_criterion final : public nvbench::stopping_criterion_base { nvbench::int64_t m_num_samples{}; public: fixed_criterion() - : nvbench::stopping_criterion{"fixed", {{"max-samples", nvbench::int64_t{42}}}} + : nvbench::stopping_criterion_base{"fixed", {{"max-samples", nvbench::int64_t{42}}}} {} // Process new measurements in the `add_measurement()` method: diff --git a/nvbench/criterion_manager.cuh b/nvbench/criterion_manager.cuh index e5c86ad..6c60993 100644 --- a/nvbench/criterion_manager.cuh +++ b/nvbench/criterion_manager.cuh @@ -32,7 +32,7 @@ namespace nvbench class criterion_manager { - std::unordered_map> m_map; + std::unordered_map> m_map; criterion_manager(); @@ -45,9 +45,9 @@ public: /** * Register a new stopping criterion. */ - nvbench::stopping_criterion& add(std::unique_ptr criterion); - nvbench::stopping_criterion& get_criterion(const std::string& name); - const nvbench::stopping_criterion& get_criterion(const std::string& name) const; + nvbench::stopping_criterion_base& add(std::unique_ptr criterion); + nvbench::stopping_criterion_base& get_criterion(const std::string& name); + const nvbench::stopping_criterion_base& get_criterion(const std::string& name) const; using params_description = std::vector>; params_description get_params_description() const; @@ -58,8 +58,8 @@ public: * * See the `custom_criterion.cu` example for usage. */ -#define NVBENCH_REGISTER_CRITERION(TYPE) \ - static nvbench::stopping_criterion& NVBENCH_UNIQUE_IDENTIFIER(TYPE) = \ - nvbench::criterion_manager::get().add(std::make_unique()) \ +#define NVBENCH_REGISTER_CRITERION(TYPE) \ + static nvbench::stopping_criterion_base &NVBENCH_UNIQUE_IDENTIFIER(TYPE) = \ + nvbench::criterion_manager::get().add(std::make_unique()) } // namespace nvbench diff --git a/nvbench/criterion_manager.cxx b/nvbench/criterion_manager.cxx index abf682c..6ba27f6 100644 --- a/nvbench/criterion_manager.cxx +++ b/nvbench/criterion_manager.cxx @@ -34,7 +34,7 @@ criterion_manager &criterion_manager::get() return registry; } -stopping_criterion& criterion_manager::get_criterion(const std::string& name) +stopping_criterion_base& criterion_manager::get_criterion(const std::string& name) { auto iter = m_map.find(name); if (iter == m_map.end()) @@ -44,7 +44,7 @@ stopping_criterion& criterion_manager::get_criterion(const std::string& name) return *iter->second.get(); } -const nvbench::stopping_criterion& criterion_manager::get_criterion(const std::string& name) const +const nvbench::stopping_criterion_base& criterion_manager::get_criterion(const std::string& name) const { auto iter = m_map.find(name); if (iter == m_map.end()) @@ -54,7 +54,7 @@ const nvbench::stopping_criterion& criterion_manager::get_criterion(const std::s return *iter->second.get(); } -stopping_criterion &criterion_manager::add(std::unique_ptr criterion) +stopping_criterion_base &criterion_manager::add(std::unique_ptr criterion) { const std::string name = criterion->get_name(); diff --git a/nvbench/detail/entropy_criterion.cuh b/nvbench/detail/entropy_criterion.cuh index e0a3763..a6478af 100644 --- a/nvbench/detail/entropy_criterion.cuh +++ b/nvbench/detail/entropy_criterion.cuh @@ -27,7 +27,7 @@ namespace nvbench::detail { -class entropy_criterion final : public stopping_criterion +class entropy_criterion final : public stopping_criterion_base { // state nvbench::int64_t m_total_samples{}; diff --git a/nvbench/detail/entropy_criterion.cxx b/nvbench/detail/entropy_criterion.cxx index c8ad16e..8b01ba1 100644 --- a/nvbench/detail/entropy_criterion.cxx +++ b/nvbench/detail/entropy_criterion.cxx @@ -26,8 +26,7 @@ namespace nvbench::detail { entropy_criterion::entropy_criterion() - : stopping_criterion{"entropy", - {{"max-angle", 0.048}, {"min-r2", 0.36}}} + : stopping_criterion_base{"entropy", {{"max-angle", 0.048}, {"min-r2", 0.36}}} { m_freq_tracker.reserve(m_entropy_tracker.capacity() * 2); m_probabilities.reserve(m_entropy_tracker.capacity() * 2); diff --git a/nvbench/detail/measure_cold.cuh b/nvbench/detail/measure_cold.cuh index 72c1b69..2b0183f 100644 --- a/nvbench/detail/measure_cold.cuh +++ b/nvbench/detail/measure_cold.cuh @@ -87,7 +87,7 @@ protected: nvbench::blocking_kernel m_blocker; nvbench::criterion_params m_criterion_params; - nvbench::stopping_criterion& m_stopping_criterion; + nvbench::stopping_criterion_base& m_stopping_criterion; bool m_run_once{false}; bool m_no_block{false}; diff --git a/nvbench/detail/stdrel_criterion.cuh b/nvbench/detail/stdrel_criterion.cuh index d9d353c..4edb74e 100644 --- a/nvbench/detail/stdrel_criterion.cuh +++ b/nvbench/detail/stdrel_criterion.cuh @@ -27,7 +27,7 @@ namespace nvbench::detail { -class stdrel_criterion final : public stopping_criterion +class stdrel_criterion final : public stopping_criterion_base { // state nvbench::int64_t m_total_samples{}; diff --git a/nvbench/detail/stdrel_criterion.cxx b/nvbench/detail/stdrel_criterion.cxx index a7a5d22..3eb3bfc 100644 --- a/nvbench/detail/stdrel_criterion.cxx +++ b/nvbench/detail/stdrel_criterion.cxx @@ -22,9 +22,9 @@ namespace nvbench::detail { stdrel_criterion::stdrel_criterion() - : stopping_criterion{"stdrel", - {{"max-noise", nvbench::detail::compat_max_noise()}, - {"min-time", nvbench::detail::compat_min_time()}}} + : stopping_criterion_base{"stdrel", + {{"max-noise", nvbench::detail::compat_max_noise()}, + {"min-time", nvbench::detail::compat_min_time()}}} {} void stdrel_criterion::do_initialize() diff --git a/nvbench/stopping_criterion.cuh b/nvbench/stopping_criterion.cuh index 6a6b523..34ab48b 100644 --- a/nvbench/stopping_criterion.cuh +++ b/nvbench/stopping_criterion.cuh @@ -70,7 +70,7 @@ public: /** * Stopping criterion interface */ -class stopping_criterion +class stopping_criterion_base { protected: std::string m_name; @@ -81,7 +81,7 @@ public: * @param name Unique name of the criterion * @param params Default values for all parameters of the criterion */ - explicit stopping_criterion(std::string name, criterion_params params) + explicit stopping_criterion_base(std::string name, criterion_params params) : m_name{std::move(name)} , m_params{params} {} diff --git a/testing/criterion_manager.cu b/testing/criterion_manager.cu index f17f2c0..0cf9204 100644 --- a/testing/criterion_manager.cu +++ b/testing/criterion_manager.cu @@ -27,11 +27,11 @@ void test_standard_criteria_exist() ASSERT(nvbench::criterion_manager::get().get_criterion("entropy").get_name() == "entropy"); } -class custom_criterion : public nvbench::stopping_criterion +class custom_criterion : public nvbench::stopping_criterion_base { public: custom_criterion() - : nvbench::stopping_criterion("custom", nvbench::criterion_params{}) + : nvbench::stopping_criterion_base("custom", nvbench::criterion_params{}) {} virtual void add_measurement(nvbench::float64_t /* measurement */) override {} @@ -47,7 +47,7 @@ void test_no_duplicates_are_allowed() bool exception_triggered = false; try { - nvbench::stopping_criterion& custom = manager.get_criterion("custom"); + nvbench::stopping_criterion_base& custom = manager.get_criterion("custom"); } catch(...) { exception_triggered = true; } @@ -57,7 +57,7 @@ void test_no_duplicates_are_allowed() custom_criterion* custom_raw = custom_ptr.get(); ASSERT(&manager.add(std::move(custom_ptr)) == custom_raw); - nvbench::stopping_criterion& custom = nvbench::criterion_manager::get().get_criterion("custom"); + nvbench::stopping_criterion_base& custom = nvbench::criterion_manager::get().get_criterion("custom"); ASSERT(custom_raw == &custom); exception_triggered = false;