From 15c148dcbba087ed1be32e0cef7188c9b609e7dc Mon Sep 17 00:00:00 2001 From: Muhammad Haseeb <14217455+mhaseeb123@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:50:26 -0700 Subject: [PATCH] Fix for logical and syntactical errors in libcudf c++ examples (#15346) This PR fixes a couple of fatal compile and runtime errors in `libcudf/strings` examples Authors: - Muhammad Haseeb (https://github.com/mhaseeb123) Approvers: - Nghia Truong (https://github.com/ttnghia) - Mark Harris (https://github.com/harrism) - David Wendt (https://github.com/davidwendt) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/15346 --- cpp/examples/build.sh | 4 +++- cpp/examples/strings/common.hpp | 4 +++- cpp/examples/strings/custom_optimized.cu | 8 ++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cpp/examples/build.sh b/cpp/examples/build.sh index 001cdeec694..424da35ad18 100755 --- a/cpp/examples/build.sh +++ b/cpp/examples/build.sh @@ -1,9 +1,11 @@ #!/bin/bash -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. # libcudf examples build script +set -euo pipefail + # Parallelism control PARALLEL_LEVEL=${PARALLEL_LEVEL:-4} diff --git a/cpp/examples/strings/common.hpp b/cpp/examples/strings/common.hpp index 0dbe6fe2b7b..65a9c100c7c 100644 --- a/cpp/examples/strings/common.hpp +++ b/cpp/examples/strings/common.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -110,7 +111,8 @@ int main(int argc, char const** argv) std::chrono::duration elapsed = std::chrono::steady_clock::now() - st; std::cout << "Wall time: " << elapsed.count() << " seconds\n"; - std::cout << "Output size " << result->view().child(1).size() << " bytes\n"; + auto const scv = cudf::strings_column_view(result->view()); + std::cout << "Output size " << scv.chars_size(rmm::cuda_stream_default) << " bytes\n"; return 0; } diff --git a/cpp/examples/strings/custom_optimized.cu b/cpp/examples/strings/custom_optimized.cu index cefa3346150..62ca19a5ca9 100644 --- a/cpp/examples/strings/custom_optimized.cu +++ b/cpp/examples/strings/custom_optimized.cu @@ -153,8 +153,12 @@ std::unique_ptr redact_strings(cudf::column_view const& names, redact_kernel<<>>( *d_names, *d_visibilities, offsets.data(), chars.data()); - // create column from offsets and chars vectors (no copy is performed) - auto result = cudf::make_strings_column(names.size(), std::move(offsets), chars.release(), {}, 0); + // create column from offsets vector (move only) + auto offsets_column = std::make_unique(std::move(offsets), rmm::device_buffer{}, 0); + + // create column for chars vector (no copy is performed) + auto result = cudf::make_strings_column( + names.size(), std::move(offsets_column), chars.release(), 0, rmm::device_buffer{}); // wait for all of the above to finish stream.synchronize();