Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to run cuIO benchmarks with pinned buffers as input #15830

Merged
merged 12 commits into from
Jun 3, 2024
Prev Previous commit
Next Next commit
implement pinned source_sink
  • Loading branch information
vuule committed May 21, 2024
commit 6a926e5601b79e91d2332962fc536140f8aa24f4
12 changes: 10 additions & 2 deletions cpp/benchmarks/io/cuio_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ cudf::io::source_info cuio_source_sink_pair::make_source_info()
switch (type) {
case io_type::FILEPATH: return cudf::io::source_info(file_name);
case io_type::HOST_BUFFER: return cudf::io::source_info(h_buffer.data(), h_buffer.size());
case io_type::PINNED_BUFFER: {
pinned_buffer.resize(h_buffer.size());
std::copy(h_buffer.begin(), h_buffer.end(), pinned_buffer.begin());
return cudf::io::source_info(pinned_buffer.data(), pinned_buffer.size());
}
case io_type::DEVICE_BUFFER: {
// TODO: make cuio_source_sink_pair stream-friendly and avoid implicit use of the default
// stream
Expand All @@ -71,7 +76,8 @@ cudf::io::sink_info cuio_source_sink_pair::make_sink_info()
switch (type) {
case io_type::VOID: return cudf::io::sink_info(void_sink.get());
case io_type::FILEPATH: return cudf::io::sink_info(file_name);
case io_type::HOST_BUFFER: [[fallthrough]];
case io_type::HOST_BUFFER:
case io_type::PINNED_BUFFER:
case io_type::DEVICE_BUFFER: return cudf::io::sink_info(&h_buffer);
default: CUDF_FAIL("invalid output type");
}
Expand All @@ -84,7 +90,8 @@ size_t cuio_source_sink_pair::size()
case io_type::FILEPATH:
return static_cast<size_t>(
std::ifstream(file_name, std::ifstream::ate | std::ifstream::binary).tellg());
case io_type::HOST_BUFFER: [[fallthrough]];
case io_type::HOST_BUFFER:
case io_type::PINNED_BUFFER:
case io_type::DEVICE_BUFFER: return h_buffer.size();
default: CUDF_FAIL("invalid output type");
}
Expand Down Expand Up @@ -208,6 +215,7 @@ io_type retrieve_io_type_enum(std::string_view io_string)
{
if (io_string == "FILEPATH") { return io_type::FILEPATH; }
if (io_string == "HOST_BUFFER") { return io_type::HOST_BUFFER; }
if (io_string == "PINNED_BUFFER") { return io_type::PINNED_BUFFER; }
if (io_string == "DEVICE_BUFFER") { return io_type::DEVICE_BUFFER; }
if (io_string == "VOID") { return io_type::VOID; }
CUDF_FAIL("Unsupported io_type.");
Expand Down
4 changes: 3 additions & 1 deletion cpp/benchmarks/io/cuio_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@

#include <cudf_test/file_utilities.hpp>

#include <cudf/detail/utilities/pinned_host_vector.hpp>
#include <cudf/io/data_sink.hpp>
#include <cudf/io/datasource.hpp>
#include <cudf/io/types.hpp>

#include <rmm/device_uvector.hpp>

// IO types supported in the benchmarks
enum class io_type {
FILEPATH, // Input/output are both files
HOST_BUFFER, // Input/output are both host buffers (pageable)
PINNED_BUFFER, // Input is a pinned host buffer, output is a host buffer (pageable)
DEVICE_BUFFER, // Input is a device buffer, output is a host buffer (pageable)
VOID
};
Expand Down Expand Up @@ -74,6 +75,7 @@ class cuio_source_sink_pair {

io_type const type;
std::vector<char> h_buffer;
cudf::detail::pinned_host_vector<char> pinned_buffer;
rmm::device_uvector<std::byte> d_buffer;
std::string const file_name;
std::unique_ptr<cudf::io::data_sink> void_sink;
Expand Down
1 change: 1 addition & 0 deletions cpp/benchmarks/io/nvbench_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ NVBENCH_DECLARE_ENUM_TYPE_STRINGS(
switch (value) {
case io_type::FILEPATH: return "FILEPATH";
case io_type::HOST_BUFFER: return "HOST_BUFFER";
case io_type::PINNED_BUFFER: return "PINNED_BUFFER";
case io_type::DEVICE_BUFFER: return "DEVICE_BUFFER";
case io_type::VOID: return "VOID";
default: return "Unknown";
Expand Down