Skip to content

Commit

Permalink
modernize- fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codereport committed Jan 10, 2022
1 parent e772fc3 commit 7af0249
Show file tree
Hide file tree
Showing 240 changed files with 808 additions and 1,399 deletions.
4 changes: 2 additions & 2 deletions cpp/benchmarks/common/generate_benchmark_input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ class data_profile {

auto get_bool_probability() const { return bool_probability; }
auto get_null_frequency() const { return null_frequency; };
auto get_cardinality() const { return cardinality; };
auto get_avg_run_length() const { return avg_run_length; };
[[nodiscard]] auto get_cardinality() const { return cardinality; };
[[nodiscard]] auto get_avg_run_length() const { return avg_run_length; };

// Users should pass integral values for bounds when setting the parameters for types that have
// discrete distributions (integers, strings, lists). Otherwise the call with have no effect.
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/copying/gather_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ template <class TypeParam, bool coalesce>
void BM_gather(benchmark::State& state)
{
const cudf::size_type source_size{(cudf::size_type)state.range(0)};
const cudf::size_type n_cols = (cudf::size_type)state.range(1);
const auto n_cols = (cudf::size_type)state.range(1);

// Every element is valid
auto data = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i; });
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/copying/scatter_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ template <class TypeParam, bool coalesce>
void BM_scatter(benchmark::State& state)
{
const cudf::size_type source_size{(cudf::size_type)state.range(0)};
const cudf::size_type n_cols = (cudf::size_type)state.range(1);
const auto n_cols = (cudf::size_type)state.range(1);

// Every element is valid
auto data = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i; });
Expand Down
10 changes: 5 additions & 5 deletions cpp/benchmarks/fixture/benchmark_fixture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ inline auto make_pool()
*/
class benchmark : public ::benchmark::Fixture {
public:
virtual void SetUp(const ::benchmark::State& state)
void SetUp(const ::benchmark::State& state) override override override override
{
mr = make_pool();
rmm::mr::set_current_device_resource(mr.get()); // set default resource to pool
}

virtual void TearDown(const ::benchmark::State& state)
void TearDown(const ::benchmark::State& state) override override override override
{
// reset default resource to the initial resource
rmm::mr::set_current_device_resource(nullptr);
mr.reset();
}

// eliminate partial override warnings (see benchmark/benchmark.h)
virtual void SetUp(::benchmark::State& st) { SetUp(const_cast<const ::benchmark::State&>(st)); }
virtual void TearDown(::benchmark::State& st)
void SetUp(::benchmark::State& st) override override override override { SetUp(const_cast<const ::benchmark::State&>(st)); }
void TearDown(::benchmark::State& st) override override override override
{
TearDown(const_cast<const ::benchmark::State&>(st));
}
Expand All @@ -102,7 +102,7 @@ class memory_stats_logger {

~memory_stats_logger() { rmm::mr::set_current_device_resource(existing_mr); }

size_t peak_memory_usage() const noexcept { return statistics_mr.get_bytes_counter().peak; }
[[nodiscard]] [[nodiscard]] [[nodiscard]] [[nodiscard]] size_t peak_memory_usage() const noexcept { return statistics_mr.get_bytes_counter().peak; }

private:
rmm::mr::device_memory_resource* existing_mr;
Expand Down
2 changes: 1 addition & 1 deletion cpp/benchmarks/lists/copying/scatter_lists_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void BM_lists_scatter(::benchmark::State& state)

const size_type base_size{(size_type)state.range(0)};
const size_type num_elements_per_row{(size_type)state.range(1)};
const size_type num_rows = (size_type)ceil(double(base_size) / num_elements_per_row);
const auto num_rows = (size_type)ceil(double(base_size) / num_elements_per_row);

auto source_base_col = make_fixed_width_column(
data_type{type_to_id<TypeParam>()}, base_size, mask_state::UNALLOCATED, stream, mr);
Expand Down
6 changes: 3 additions & 3 deletions cpp/benchmarks/type_dispatcher/type_dispatcher_benchmark.cu
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ void launch_kernel(cudf::mutable_table_view input, T** d_ptr, int work_per_threa
template <class TypeParam, FunctorType functor_type, DispatchingType dispatching_type>
void type_dispatcher_benchmark(::benchmark::State& state)
{
const cudf::size_type source_size = static_cast<cudf::size_type>(state.range(1));
const auto source_size = static_cast<cudf::size_type>(state.range(1));

const cudf::size_type n_cols = static_cast<cudf::size_type>(state.range(0));
const auto n_cols = static_cast<cudf::size_type>(state.range(0));

const cudf::size_type work_per_thread = static_cast<cudf::size_type>(state.range(2));
const auto work_per_thread = static_cast<cudf::size_type>(state.range(2));

auto data = cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i; });

Expand Down
12 changes: 6 additions & 6 deletions cpp/include/cudf/aggregation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ class aggregation {
Kind kind; ///< The aggregation to perform
virtual ~aggregation() = default;

virtual bool is_equal(aggregation const& other) const { return kind == other.kind; }
virtual size_t do_hash() const { return std::hash<int>{}(kind); }
virtual std::unique_ptr<aggregation> clone() const = 0;
[[nodiscard]] virtual bool is_equal(aggregation const& other) const { return kind == other.kind; }
[[nodiscard]] virtual size_t do_hash() const { return std::hash<int>{}(kind); }
[[nodiscard]] virtual std::unique_ptr<aggregation> clone() const = 0;

// override functions for compound aggregations
virtual std::vector<std::unique_ptr<aggregation>> get_simple_aggregations(
Expand All @@ -118,7 +118,7 @@ class aggregation {
*/
class rolling_aggregation : public virtual aggregation {
public:
~rolling_aggregation() = default;
~rolling_aggregation() override = default;

protected:
rolling_aggregation() {}
Expand All @@ -130,7 +130,7 @@ class rolling_aggregation : public virtual aggregation {
*/
class groupby_aggregation : public virtual aggregation {
public:
~groupby_aggregation() = default;
~groupby_aggregation() override = default;

protected:
groupby_aggregation() {}
Expand All @@ -141,7 +141,7 @@ class groupby_aggregation : public virtual aggregation {
*/
class groupby_scan_aggregation : public virtual aggregation {
public:
~groupby_scan_aggregation() = default;
~groupby_scan_aggregation() override = default;

protected:
groupby_scan_aggregation() {}
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/cudf/ast/detail/expression_evaluator.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct expression_result {
subclass().template set_value<Element>(index, result);
}

CUDA_DEVICE_CALLABLE bool is_valid() const { return subclass().is_valid(); }
[[nodiscard]] CUDA_DEVICE_CALLABLE bool is_valid() const { return subclass().is_valid(); }

CUDA_DEVICE_CALLABLE T value() const { return subclass().value(); }
};
Expand Down Expand Up @@ -113,7 +113,7 @@ struct value_expression_result
/**
* @brief Returns true if the underlying data is valid and false otherwise.
*/
CUDA_DEVICE_CALLABLE bool is_valid() const
[[nodiscard]] CUDA_DEVICE_CALLABLE bool is_valid() const
{
if constexpr (has_nulls) { return _obj.has_value(); }
return true;
Expand Down Expand Up @@ -179,7 +179,7 @@ struct mutable_column_expression_result
/**
* @brief Not implemented for this specialization.
*/
CUDA_DEVICE_CALLABLE bool is_valid() const
[[nodiscard]] CUDA_DEVICE_CALLABLE bool is_valid() const
{
// Not implemented since it would require modifying the API in the parent class to accept an
// index.
Expand All @@ -191,7 +191,7 @@ struct mutable_column_expression_result
/**
* @brief Not implemented for this specialization.
*/
CUDA_DEVICE_CALLABLE mutable_column_device_view value() const
[[nodiscard]] CUDA_DEVICE_CALLABLE mutable_column_device_view value() const
{
// Not implemented since it would require modifying the API in the parent class to accept an
// index.
Expand Down
10 changes: 5 additions & 5 deletions cpp/include/cudf/ast/detail/expression_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class expression_parser {
*
* @return cudf::data_type
*/
cudf::data_type output_type() const;
[[nodiscard]] cudf::data_type output_type() const;

/**
* @brief Visit a literal expression.
Expand Down Expand Up @@ -206,10 +206,10 @@ class expression_parser {
*/
class intermediate_counter {
public:
intermediate_counter() : used_values(), max_used(0) {}
intermediate_counter() : used_values() {}
cudf::size_type take();
void give(cudf::size_type value);
cudf::size_type get_max_used() const { return max_used; }
[[nodiscard]] cudf::size_type get_max_used() const { return max_used; }

private:
/**
Expand All @@ -221,10 +221,10 @@ class expression_parser {
*
* @return cudf::size_type Smallest value not already in the container.
*/
cudf::size_type find_first_missing() const;
[[nodiscard]] cudf::size_type find_first_missing() const;

std::vector<cudf::size_type> used_values;
cudf::size_type max_used;
cudf::size_type max_used{0};
};

expression_device_view device_expression_data; ///< The collection of data required to evaluate
Expand Down
26 changes: 13 additions & 13 deletions cpp/include/cudf/ast/expressions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class expression_parser;
struct expression {
virtual cudf::size_type accept(detail::expression_parser& visitor) const = 0;

bool may_evaluate_null(table_view const& left, rmm::cuda_stream_view stream) const
[[nodiscard]] bool may_evaluate_null(table_view const& left, rmm::cuda_stream_view stream) const
{
return may_evaluate_null(left, left, stream);
}

virtual bool may_evaluate_null(table_view const& left,
[[nodiscard]] virtual bool may_evaluate_null(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream) const = 0;

Expand Down Expand Up @@ -173,14 +173,14 @@ class literal : public expression {
*
* @return cudf::data_type
*/
cudf::data_type get_data_type() const { return get_value().type(); }
[[nodiscard]] cudf::data_type get_data_type() const { return get_value().type(); }

/**
* @brief Get the value object.
*
* @return cudf::detail::fixed_width_scalar_device_view_base
*/
cudf::detail::fixed_width_scalar_device_view_base get_value() const { return value; }
[[nodiscard]] cudf::detail::fixed_width_scalar_device_view_base get_value() const { return value; }

/**
* @brief Accepts a visitor class.
Expand All @@ -190,7 +190,7 @@ class literal : public expression {
*/
cudf::size_type accept(detail::expression_parser& visitor) const override;

bool may_evaluate_null(table_view const& left,
[[nodiscard]] bool may_evaluate_null(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream) const override
{
Expand All @@ -202,7 +202,7 @@ class literal : public expression {
*
* @return bool
*/
bool is_valid(rmm::cuda_stream_view stream) const { return scalar.is_valid(stream); }
[[nodiscard]] bool is_valid(rmm::cuda_stream_view stream) const { return scalar.is_valid(stream); }

private:
cudf::scalar const& scalar;
Expand Down Expand Up @@ -232,22 +232,22 @@ class column_reference : public expression {
*
* @return cudf::size_type
*/
cudf::size_type get_column_index() const { return column_index; }
[[nodiscard]] cudf::size_type get_column_index() const { return column_index; }

/**
* @brief Get the table source.
*
* @return table_reference
*/
table_reference get_table_source() const { return table_source; }
[[nodiscard]] table_reference get_table_source() const { return table_source; }

/**
* @brief Get the data type.
*
* @param table Table used to determine types.
* @return cudf::data_type
*/
cudf::data_type get_data_type(table_view const& table) const
[[nodiscard]] cudf::data_type get_data_type(table_view const& table) const
{
return table.column(get_column_index()).type();
}
Expand All @@ -259,7 +259,7 @@ class column_reference : public expression {
* @param right_table Right table used to determine types.
* @return cudf::data_type
*/
cudf::data_type get_data_type(table_view const& left_table, table_view const& right_table) const
[[nodiscard]] cudf::data_type get_data_type(table_view const& left_table, table_view const& right_table) const
{
auto const table = [&] {
if (get_table_source() == table_reference::LEFT) {
Expand All @@ -281,7 +281,7 @@ class column_reference : public expression {
*/
cudf::size_type accept(detail::expression_parser& visitor) const override;

bool may_evaluate_null(table_view const& left,
[[nodiscard]] bool may_evaluate_null(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream) const override
{
Expand Down Expand Up @@ -327,7 +327,7 @@ class operation : public expression {
*
* @return ast_operator
*/
ast_operator get_operator() const { return op; }
[[nodiscard]] ast_operator get_operator() const { return op; }

/**
* @brief Get the operands.
Expand All @@ -344,7 +344,7 @@ class operation : public expression {
*/
cudf::size_type accept(detail::expression_parser& visitor) const override;

bool may_evaluate_null(table_view const& left,
[[nodiscard]] bool may_evaluate_null(table_view const& left,
table_view const& right,
rmm::cuda_stream_view stream) const override
{
Expand Down
Loading

0 comments on commit 7af0249

Please sign in to comment.