-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[draft] Add
bytes_per_second
to groupby nvbench benchmarks
This patch adds memory statistics for the GROUPBY_NVBENCH benchmarks. For this purpose helper functions are introduced to compute the payload size for: - Column - Table - Groupby execution results This patch relates to #13735.
- Loading branch information
Martin Marenz
committed
Aug 30, 2023
1 parent
7b9f4a1
commit 405ca60
Showing
7 changed files
with
191 additions
and
11 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,71 @@ | ||
/* | ||
* Copyright (c) 2020-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 "memory_statistics.hpp" | ||
|
||
#include <cudf/column/column.hpp> | ||
#include <cudf/null_mask.hpp> | ||
|
||
#include <numeric> | ||
|
||
uint64_t required_bytes(const cudf::column_view& column) | ||
{ | ||
uint64_t read_bytes = 0; | ||
|
||
switch (column.type().id()) { | ||
case cudf::type_id::STRING: | ||
CUDF_FAIL("required bytes not implemented for STRING columns"); | ||
break; | ||
case cudf::type_id::STRUCT: // fallthrough | ||
case cudf::type_id::LIST: | ||
read_bytes += std::accumulate( | ||
column.child_begin(), column.child_end(), 0, [](uint64_t acc, const auto& col) { | ||
return acc + required_bytes(col); | ||
}); | ||
break; | ||
case cudf::type_id::DICTIONARY32: | ||
CUDF_FAIL("required bytes not implemented for DICTIONARY columns"); | ||
break; | ||
default: | ||
CUDF_EXPECTS(cudf::is_fixed_width(column.type()), "Invalid element type"); | ||
read_bytes += column.size() * cudf::size_of(column.type()); | ||
break; | ||
} | ||
if (column.nullable()) { read_bytes += cudf::bitmask_allocation_size_bytes(column.size()); } | ||
|
||
return read_bytes; | ||
} | ||
|
||
uint64_t required_bytes(const cudf::table_view& table) | ||
{ | ||
return std::accumulate(table.begin(), table.end(), 0, [](uint64_t acc, const auto& col) { | ||
return acc + required_bytes(col); | ||
}); | ||
} | ||
|
||
uint64_t required_bytes( | ||
const cudf::host_span<cudf::groupby::aggregation_result>& aggregation_results) | ||
{ | ||
uint64_t read_bytes = 0; | ||
|
||
for (auto const& aggregation : aggregation_results) { // vector of aggregation results | ||
for (auto const& col : aggregation.results) { // vector of columns per result | ||
read_bytes += required_bytes(col->view()); | ||
} | ||
} | ||
|
||
return read_bytes; | ||
} |
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,57 @@ | ||
/* | ||
* Copyright (c) 2020-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/column/column_view.hpp> | ||
#include <cudf/groupby.hpp> | ||
#include <cudf/table/table_view.hpp> | ||
#include <cudf/utilities/span.hpp> | ||
|
||
/** | ||
* @brief Calculate the number of bytes needed to completely read/write the provided column. | ||
* | ||
* The functions computes only the size of the payload of the column in bytes, it excludes | ||
* any metadata. | ||
* | ||
* @param column View of the input column | ||
* @returns Number of bytes needed to read or write the column. | ||
*/ | ||
uint64_t required_bytes(const cudf::column_view& column); | ||
|
||
/** | ||
* @brief Calculate the number of bytes needed to completely read/write the provided table. | ||
* | ||
* The functions computes only the size of the payload of the table in bytes, it excludes | ||
* any metadata. | ||
* | ||
* @param table View of the input table. | ||
* @returns Number of bytes needed to read or write the table. | ||
*/ | ||
uint64_t required_bytes(const cudf::table_view& table); | ||
|
||
/** | ||
* @brief Calculate the number of bytes needed to completely read/write the provided sequence of | ||
* aggregation results. | ||
* | ||
* The functions computes only the size of the payload of the aggregation results in bytes, it | ||
* excludes any metadata. | ||
* | ||
* @param aggregation_results Sequence of aggregation results from groupby execution. | ||
* @returns Number of bytes needed to read or write the aggregation results. | ||
*/ | ||
uint64_t required_bytes( | ||
const cudf::host_span<cudf::groupby::aggregation_result>& aggregation_results); |
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
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