diff --git a/nvbench/detail/l2flush.cuh b/nvbench/detail/l2flush.cuh index aefbfef..f85b3e7 100644 --- a/nvbench/detail/l2flush.cuh +++ b/nvbench/detail/l2flush.cuh @@ -35,7 +35,7 @@ struct l2flush if (m_l2_size > 0) { void *buffer = m_l2_buffer; - NVBENCH_CUDA_CALL(cudaMalloc(&buffer, m_l2_size)); + NVBENCH_CUDA_CALL(cudaMalloc(&buffer, static_cast(m_l2_size))); m_l2_buffer = reinterpret_cast(buffer); } } @@ -52,7 +52,8 @@ struct l2flush { if (m_l2_size > 0) { - NVBENCH_CUDA_CALL(cudaMemsetAsync(m_l2_buffer, 0, m_l2_size, stream)); + NVBENCH_CUDA_CALL( + cudaMemsetAsync(m_l2_buffer, 0, static_cast(m_l2_size), stream)); } } diff --git a/nvbench/detail/ring_buffer.cuh b/nvbench/detail/ring_buffer.cuh index 645fa03..77d652a 100644 --- a/nvbench/detail/ring_buffer.cuh +++ b/nvbench/detail/ring_buffer.cuh @@ -34,6 +34,15 @@ namespace nvbench::detail template struct ring_buffer { +private: + using buffer_t = typename std::vector; + using diff_t = typename buffer_t::difference_type; + + buffer_t m_buffer; + std::size_t m_index{0}; + bool m_full{false}; + +public: /** * Create a new ring buffer with the requested capacity. */ @@ -49,9 +58,9 @@ struct ring_buffer [[nodiscard]] auto begin() { return m_buffer.begin(); } [[nodiscard]] auto begin() const { return m_buffer.begin(); } [[nodiscard]] auto cbegin() const { return m_buffer.cbegin(); } - [[nodiscard]] auto end() { return m_buffer.begin() + this->size(); } - [[nodiscard]] auto end() const { return m_buffer.begin() + this->size(); } - [[nodiscard]] auto cend() const { return m_buffer.cbegin() + this->size(); } + [[nodiscard]] auto end() { return m_buffer.begin() + static_cast(this->size()); } + [[nodiscard]] auto end() const { return m_buffer.begin() + static_cast(this->size()); } + [[nodiscard]] auto cend() const { return m_buffer.cbegin() + static_cast(this->size()); } // clang-format on /** @} */ @@ -113,11 +122,6 @@ struct ring_buffer return m_buffer[back_index]; } /**@}*/ - -private: - std::vector m_buffer; - std::size_t m_index{0}; - bool m_full{false}; }; } // namespace nvbench::detail diff --git a/nvbench/device_info.cuh b/nvbench/device_info.cuh index f0694df..98184cf 100644 --- a/nvbench/device_info.cuh +++ b/nvbench/device_info.cuh @@ -154,7 +154,7 @@ struct device_info [[nodiscard]] std::size_t get_global_memory_bus_bandwidth() const { // 2 is for DDR, CHAR_BITS to convert bus_width to bytes. return 2 * this->get_global_memory_bus_peak_clock_rate() * - (this->get_global_memory_bus_width() / CHAR_BIT); + static_cast(this->get_global_memory_bus_width() / CHAR_BIT); } /// @return The size of the L2 cache in bytes. diff --git a/nvbench/device_manager.cu b/nvbench/device_manager.cu index 136b20a..260275b 100644 --- a/nvbench/device_manager.cu +++ b/nvbench/device_manager.cu @@ -16,12 +16,12 @@ * limitations under the License. */ -#include +#include #include #include - -#include +#include +#include namespace nvbench { @@ -44,4 +44,13 @@ device_manager::device_manager() } } +const nvbench::device_info &device_manager::get_device(int id) +{ + if (id < 0) + { + NVBENCH_THROW(std::runtime_error, "Negative index: {}.", id); + } + return m_devices.at(static_cast(id)); +} + } // namespace nvbench diff --git a/nvbench/device_manager.cuh b/nvbench/device_manager.cuh index 8e6fe9d..36082b8 100644 --- a/nvbench/device_manager.cuh +++ b/nvbench/device_manager.cuh @@ -54,7 +54,7 @@ struct device_manager /** * @return The device_info object corresponding to `id`. */ - [[nodiscard]] const nvbench::device_info &get_device(int id) { return m_devices.at(id); } + [[nodiscard]] const nvbench::device_info &get_device(int id); /** * @return A vector containing device_info objects for all detected CUDA diff --git a/nvbench/int64_axis.cuh b/nvbench/int64_axis.cuh index baa7641..812aa58 100644 --- a/nvbench/int64_axis.cuh +++ b/nvbench/int64_axis.cuh @@ -69,13 +69,16 @@ struct int64_axis final : public axis_base int64_axis_flags get_flags() const { return m_flags; } // Helper functions for pow2 conversions: - static nvbench::int64_t compute_pow2(nvbench::int64_t exponent) { return 1ll << exponent; } + static nvbench::int64_t compute_pow2(nvbench::int64_t exponent) + { + return nvbench::int64_t{1} << exponent; + } // UB if value < 0. static nvbench::int64_t compute_log2(nvbench::int64_t value) { // TODO use functions in C++20? - nvbench::uint64_t bits = static_cast(value); + nvbench::uint64_t bits = static_cast(value); nvbench::int64_t exponent = 0; while ((bits >>= 1) != 0ull) { diff --git a/nvbench/launch.cuh b/nvbench/launch.cuh index 0cb4961..f31c823 100644 --- a/nvbench/launch.cuh +++ b/nvbench/launch.cuh @@ -43,9 +43,9 @@ struct launch // move-only launch(const launch &) = delete; - launch(launch &&) = default; + launch(launch &&) = delete; launch &operator=(const launch &) = delete; - launch &operator=(launch &&) = default; + launch &operator=(launch &&) = delete; /** * @return a CUDA stream that all kernels and other stream-ordered CUDA work diff --git a/nvbench/option_parser.cu b/nvbench/option_parser.cu index d1378eb..a8db8ef 100644 --- a/nvbench/option_parser.cu +++ b/nvbench/option_parser.cu @@ -365,7 +365,7 @@ void option_parser::parse_range(option_parser::arg_iterator_t first, } auto check_params = [&first, &last](std::size_t num_params) { - const std::size_t rem_args = std::distance(first, last) - 1; + const std::size_t rem_args = static_cast(std::distance(first, last) - 1); if (rem_args < num_params) { NVBENCH_THROW(std::runtime_error, @@ -444,7 +444,7 @@ void option_parser::parse_range(option_parser::arg_iterator_t first, this->disable_blocking_kernel(); first += 1; } - else if (arg == "--quiet" | arg == "-q") + else if (arg == "--quiet" || arg == "-q") { // Setting this flag prevents the default stdout printer from being // added. @@ -726,7 +726,7 @@ try catch (std::invalid_argument &) {} - m_benchmarks.push_back(idx >= 0 ? mgr.get_benchmark(idx).clone() + m_benchmarks.push_back(idx >= 0 ? mgr.get_benchmark(static_cast(idx)).clone() : mgr.get_benchmark(name).clone()); // Initialize the new benchmark with any global arguments: diff --git a/nvbench/printer_base.cuh b/nvbench/printer_base.cuh index 3bb20f7..960a4fc 100644 --- a/nvbench/printer_base.cuh +++ b/nvbench/printer_base.cuh @@ -78,9 +78,9 @@ struct printer_base // move-only printer_base(const printer_base &) = delete; - printer_base(printer_base &&) = default; + printer_base(printer_base &&) = delete; printer_base &operator=(const printer_base &) = delete; - printer_base &operator=(printer_base &&) = default; + printer_base &operator=(printer_base &&) = delete; /*! * Called once with the command line arguments used to invoke the current diff --git a/nvbench/type_axis.cxx b/nvbench/type_axis.cxx index e678ff9..f89ec1d 100644 --- a/nvbench/type_axis.cxx +++ b/nvbench/type_axis.cxx @@ -67,7 +67,7 @@ std::size_t type_axis::get_type_index(const std::string &input_string) const m_input_strings); } - return it - m_input_strings.cbegin(); + return static_cast(it - m_input_strings.cbegin()); } } // namespace nvbench