-
Notifications
You must be signed in to change notification settings - Fork 916
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,008 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <benchmarks/common/generate_input.hpp> | ||
#include <benchmarks/fixture/rmm_pool_raii.hpp> | ||
|
||
#include <cudf_test/column_wrapper.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
#include <random> | ||
|
||
inline std::unique_ptr<cudf::table> create_lists_data(nvbench::state& state) | ||
{ | ||
const size_t size_bytes(state.get_int64("size_bytes")); | ||
const cudf::size_type depth{static_cast<cudf::size_type>(state.get_int64("depth"))}; | ||
auto const null_frequency{state.get_float64("null_frequency")}; | ||
|
||
data_profile table_profile; | ||
table_profile.set_distribution_params(cudf::type_id::LIST, distribution_id::UNIFORM, 0, 5); | ||
table_profile.set_list_depth(depth); | ||
table_profile.set_null_probability(null_frequency); | ||
return create_random_table({cudf::type_id::LIST}, table_size_bytes{size_bytes}, table_profile); | ||
} | ||
|
||
inline std::unique_ptr<cudf::table> create_structs_data(nvbench::state& state, | ||
cudf::size_type const n_cols = 1) | ||
{ | ||
using Type = int; | ||
using column_wrapper = cudf::test::fixed_width_column_wrapper<Type>; | ||
std::default_random_engine generator; | ||
std::uniform_int_distribution<int> distribution(0, 100); | ||
|
||
const cudf::size_type n_rows{static_cast<cudf::size_type>(state.get_int64("NumRows"))}; | ||
const cudf::size_type depth{static_cast<cudf::size_type>(state.get_int64("Depth"))}; | ||
const bool nulls{static_cast<bool>(state.get_int64("Nulls"))}; | ||
|
||
// Create columns with values in the range [0,100) | ||
std::vector<column_wrapper> columns; | ||
columns.reserve(n_cols); | ||
std::generate_n(std::back_inserter(columns), n_cols, [&]() { | ||
auto const elements = cudf::detail::make_counting_transform_iterator( | ||
0, [&](auto row) { return distribution(generator); }); | ||
if (!nulls) return column_wrapper(elements, elements + n_rows); | ||
auto valids = | ||
cudf::detail::make_counting_transform_iterator(0, [](auto i) { return i % 10 != 0; }); | ||
return column_wrapper(elements, elements + n_rows, valids); | ||
}); | ||
|
||
std::vector<std::unique_ptr<cudf::column>> cols; | ||
std::transform(columns.begin(), columns.end(), std::back_inserter(cols), [](column_wrapper& col) { | ||
return col.release(); | ||
}); | ||
|
||
std::vector<std::unique_ptr<cudf::column>> child_cols = std::move(cols); | ||
// Nest the child columns in a struct, then nest that struct column inside another | ||
// struct column up to the desired depth | ||
for (int i = 0; i < depth; i++) { | ||
std::vector<bool> struct_validity; | ||
std::uniform_int_distribution<int> bool_distribution(0, 100 * (i + 1)); | ||
std::generate_n( | ||
std::back_inserter(struct_validity), n_rows, [&]() { return bool_distribution(generator); }); | ||
cudf::test::structs_column_wrapper struct_col(std::move(child_cols), struct_validity); | ||
child_cols = std::vector<std::unique_ptr<cudf::column>>{}; | ||
child_cols.push_back(struct_col.release()); | ||
} | ||
|
||
// Create table view | ||
return std::make_unique<cudf::table>(std::move(child_cols)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "nested_types_common.hpp" | ||
#include "rank_types_common.hpp" | ||
|
||
#include <cudf/sorting.hpp> | ||
|
||
#include <cudf_test/column_utilities.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
template <cudf::rank_method method> | ||
void nvbench_rank_lists(nvbench::state& state, nvbench::type_list<nvbench::enum_type<method>>) | ||
{ | ||
cudf::rmm_pool_raii pool_raii; | ||
|
||
auto const table = create_lists_data(state); | ||
|
||
auto const null_frequency{state.get_float64("null_frequency")}; | ||
|
||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
cudf::rank(table->view().column(0), | ||
method, | ||
cudf::order::ASCENDING, | ||
null_frequency ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE, | ||
cudf::null_order::AFTER, | ||
rmm::mr::get_current_device_resource()); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH_TYPES(nvbench_rank_lists, NVBENCH_TYPE_AXES(methods)) | ||
.set_name("rank_lists") | ||
.add_int64_power_of_two_axis("size_bytes", {10, 18, 24, 28}) | ||
.add_int64_axis("depth", {1, 4}) | ||
.add_float64_axis("null_frequency", {0, 0.2}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "nested_types_common.hpp" | ||
#include "rank_types_common.hpp" | ||
|
||
#include <cudf/sorting.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
template <cudf::rank_method method> | ||
void nvbench_rank_structs(nvbench::state& state, nvbench::type_list<nvbench::enum_type<method>>) | ||
{ | ||
cudf::rmm_pool_raii pool_raii; | ||
|
||
auto const table = create_structs_data(state); | ||
|
||
const bool nulls{static_cast<bool>(state.get_int64("Nulls"))}; | ||
|
||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
cudf::rank(table->view().column(0), | ||
method, | ||
cudf::order::ASCENDING, | ||
nulls ? cudf::null_policy::INCLUDE : cudf::null_policy::EXCLUDE, | ||
cudf::null_order::AFTER, | ||
rmm::mr::get_current_device_resource()); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH_TYPES(nvbench_rank_structs, NVBENCH_TYPE_AXES(methods)) | ||
.set_name("rank_structs") | ||
.add_int64_power_of_two_axis("NumRows", {10, 18, 26}) | ||
.add_int64_axis("Depth", {0, 1, 8}) | ||
.add_int64_axis("Nulls", {0, 1}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <cudf/aggregation.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
enum class rank_method : int32_t {}; | ||
|
||
NVBENCH_DECLARE_ENUM_TYPE_STRINGS( | ||
cudf::rank_method, | ||
[](cudf::rank_method value) { | ||
switch (value) { | ||
case cudf::rank_method::FIRST: return "FIRST"; | ||
case cudf::rank_method::AVERAGE: return "AVERAGE"; | ||
case cudf::rank_method::MIN: return "MIN"; | ||
case cudf::rank_method::MAX: return "MAX"; | ||
case cudf::rank_method::DENSE: return "DENSE"; | ||
default: return "unknown"; | ||
} | ||
}, | ||
[](cudf::rank_method value) { | ||
switch (value) { | ||
case cudf::rank_method::FIRST: return "cudf::rank_method::FIRST"; | ||
case cudf::rank_method::AVERAGE: return "cudf::rank_method::AVERAGE"; | ||
case cudf::rank_method::MIN: return "cudf::rank_method::MIN"; | ||
case cudf::rank_method::MAX: return "cudf::rank_method::MAX"; | ||
case cudf::rank_method::DENSE: return "cudf::rank_method::DENSE"; | ||
default: return "unknown"; | ||
} | ||
}) | ||
|
||
using methods = nvbench::enum_type_list<cudf::rank_method::AVERAGE, | ||
cudf::rank_method::DENSE, | ||
cudf::rank_method::FIRST, | ||
cudf::rank_method::MAX, | ||
cudf::rank_method::MIN>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.